mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 07:16:27 -04:00
fix: #664
This commit is contained in:
parent
4923370897
commit
0d906e0adf
@ -107,9 +107,6 @@ public final class NetworkUtils {
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
Map<String, List<String>> properties = conn.getRequestProperties();
|
||||
String method = conn.getRequestMethod();
|
||||
boolean doInput = conn.getDoInput();
|
||||
boolean doOutput = conn.getDoOutput();
|
||||
boolean useCaches = conn.getUseCaches();
|
||||
int code = conn.getResponseCode();
|
||||
if (code >= 300 && code <= 307 && code != 306 && code != 304) {
|
||||
String newURL = conn.getHeaderField("Location");
|
||||
@ -122,9 +119,6 @@ public final class NetworkUtils {
|
||||
HttpURLConnection redirected = (HttpURLConnection) new URL(conn.getURL(), encodeLocation(newURL)).openConnection();
|
||||
properties.forEach((key, value) -> value.forEach(element -> redirected.addRequestProperty(key, element)));
|
||||
redirected.setRequestMethod(method);
|
||||
redirected.setDoInput(doInput);
|
||||
redirected.setDoOutput(doOutput);
|
||||
redirected.setUseCaches(useCaches);
|
||||
conn = redirected;
|
||||
++redirect;
|
||||
} else {
|
||||
@ -159,10 +153,9 @@ public final class NetworkUtils {
|
||||
|
||||
HttpURLConnection con = createConnection(url);
|
||||
con.setRequestMethod("POST");
|
||||
con.setDoOutput(true);
|
||||
con.setRequestProperty("Content-Type", contentType + "; charset=utf-8");
|
||||
con.setRequestProperty("Content-Length", "" + bytes.length);
|
||||
con.setDoOutput(true);
|
||||
con = resolveConnection(con);
|
||||
try (OutputStream os = con.getOutputStream()) {
|
||||
os.write(bytes);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user