From 0d906e0adf98bd885e90ddf55a83460166aee6f8 Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Thu, 6 Feb 2020 12:46:38 +0800 Subject: [PATCH] fix: #664 --- .../java/org/jackhuang/hmcl/util/io/NetworkUtils.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/NetworkUtils.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/NetworkUtils.java index 7a761069e..539af8517 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/NetworkUtils.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/io/NetworkUtils.java @@ -107,9 +107,6 @@ public final class NetworkUtils { conn.setInstanceFollowRedirects(false); Map> 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); }