mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-08 11:25:46 -04:00
Set the network timeout to 8000ms. (#2650)
This commit is contained in:
parent
8f2afdfcff
commit
3f1be961a6
@ -35,6 +35,7 @@ import static org.jackhuang.hmcl.util.StringUtils.*;
|
||||
public final class NetworkUtils {
|
||||
public static final String PARAMETER_SEPARATOR = "&";
|
||||
public static final String NAME_VALUE_SEPARATOR = "=";
|
||||
private static final int TIME_OUT = 8000;
|
||||
|
||||
private NetworkUtils() {
|
||||
}
|
||||
@ -88,8 +89,8 @@ public final class NetworkUtils {
|
||||
public static URLConnection createConnection(URL url) throws IOException {
|
||||
URLConnection connection = url.openConnection();
|
||||
connection.setUseCaches(false);
|
||||
connection.setConnectTimeout(5000);
|
||||
connection.setReadTimeout(5000);
|
||||
connection.setConnectTimeout(TIME_OUT);
|
||||
connection.setReadTimeout(TIME_OUT);
|
||||
connection.setRequestProperty("Accept-Language", Locale.getDefault().toString());
|
||||
return connection;
|
||||
}
|
||||
@ -142,10 +143,9 @@ public final class NetworkUtils {
|
||||
public static HttpURLConnection resolveConnection(HttpURLConnection conn) throws IOException {
|
||||
int redirect = 0;
|
||||
while (true) {
|
||||
|
||||
conn.setUseCaches(false);
|
||||
conn.setConnectTimeout(8000);
|
||||
conn.setReadTimeout(8000);
|
||||
conn.setConnectTimeout(TIME_OUT);
|
||||
conn.setReadTimeout(TIME_OUT);
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
Map<String, List<String>> properties = conn.getRequestProperties();
|
||||
String method = conn.getRequestMethod();
|
||||
|
Loading…
x
Reference in New Issue
Block a user