fix: #661
This commit is contained in:
@@ -162,7 +162,7 @@ public final class LauncherHelper {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.thenRunAsync(Schedulers.javafx(), () -> emitStatus(LoadingState.LOGGING_IN))
|
.thenRunAsync(Schedulers.javafx(), () -> emitStatus(LoadingState.LOGGING_IN))
|
||||||
.thenSupplyAsync(i18n("account.methods"), () -> {
|
.thenSupplyAsync(i18n("launch.state.logging_in"), () -> {
|
||||||
try {
|
try {
|
||||||
return account.logIn();
|
return account.logIn();
|
||||||
} catch (CredentialExpiredException e) {
|
} catch (CredentialExpiredException e) {
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ public final class NetworkUtils {
|
|||||||
conn.setReadTimeout(15000);
|
conn.setReadTimeout(15000);
|
||||||
conn.setInstanceFollowRedirects(false);
|
conn.setInstanceFollowRedirects(false);
|
||||||
Map<String, List<String>> properties = conn.getRequestProperties();
|
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();
|
int code = conn.getResponseCode();
|
||||||
if (code >= 300 && code <= 307 && code != 306 && code != 304) {
|
if (code >= 300 && code <= 307 && code != 306 && code != 304) {
|
||||||
String newURL = conn.getHeaderField("Location");
|
String newURL = conn.getHeaderField("Location");
|
||||||
@@ -117,6 +121,10 @@ public final class NetworkUtils {
|
|||||||
|
|
||||||
HttpURLConnection redirected = (HttpURLConnection) new URL(conn.getURL(), encodeLocation(newURL)).openConnection();
|
HttpURLConnection redirected = (HttpURLConnection) new URL(conn.getURL(), encodeLocation(newURL)).openConnection();
|
||||||
properties.forEach((key, value) -> value.forEach(element -> redirected.addRequestProperty(key, element)));
|
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;
|
conn = redirected;
|
||||||
++redirect;
|
++redirect;
|
||||||
} else {
|
} else {
|
||||||
@@ -127,7 +135,9 @@ public final class NetworkUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String doGet(URL url) throws IOException {
|
public static String doGet(URL url) throws IOException {
|
||||||
return IOUtils.readFullyAsString(createConnection(url).getInputStream());
|
HttpURLConnection con = createConnection(url);
|
||||||
|
con = resolveConnection(con);
|
||||||
|
return IOUtils.readFullyAsString(con.getInputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String doPost(URL u, Map<String, String> params) throws IOException {
|
public static String doPost(URL u, Map<String, String> params) throws IOException {
|
||||||
@@ -149,9 +159,10 @@ public final class NetworkUtils {
|
|||||||
|
|
||||||
HttpURLConnection con = createConnection(url);
|
HttpURLConnection con = createConnection(url);
|
||||||
con.setRequestMethod("POST");
|
con.setRequestMethod("POST");
|
||||||
con.setDoOutput(true);
|
|
||||||
con.setRequestProperty("Content-Type", contentType + "; charset=utf-8");
|
con.setRequestProperty("Content-Type", contentType + "; charset=utf-8");
|
||||||
con.setRequestProperty("Content-Length", "" + bytes.length);
|
con.setRequestProperty("Content-Length", "" + bytes.length);
|
||||||
|
con.setDoOutput(true);
|
||||||
|
con = resolveConnection(con);
|
||||||
try (OutputStream os = con.getOutputStream()) {
|
try (OutputStream os = con.getOutputStream()) {
|
||||||
os.write(bytes);
|
os.write(bytes);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user