diff --git a/launcher-bootstrap/src/main/java/com/skcraft/launcher/bootstrap/HttpRequest.java b/launcher-bootstrap/src/main/java/com/skcraft/launcher/bootstrap/HttpRequest.java index b07e874..94d3737 100644 --- a/launcher-bootstrap/src/main/java/com/skcraft/launcher/bootstrap/HttpRequest.java +++ b/launcher-bootstrap/src/main/java/com/skcraft/launcher/bootstrap/HttpRequest.java @@ -13,7 +13,10 @@ import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import java.io.*; -import java.net.*; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -116,7 +119,7 @@ throw new IOException("Too many redirects!"); } - HttpURLConnection conn = (HttpURLConnection) reformat(url).openConnection(); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Java) SKMCLauncher"); conn.setInstanceFollowRedirects(false); @@ -154,7 +157,6 @@ case 307: case 308: String location = conn.getHeaderField("Location"); - location = URLDecoder.decode(location, "UTF-8"); redirectCount++; return runRequest(new URL(this.url, location)); @@ -359,27 +361,6 @@ } /** - * URL may contain spaces and other nasties that will cause a failure. - * - * @param existing the existing URL to transform - * @return the new URL, or old one if there was a failure - */ - private static URL reformat(URL existing) { - try { - URL url = new URL(existing.toString()); - URI uri = new URI( - url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), - url.getPath(), url.getQuery(), url.getRef()); - url = uri.toURL(); - return url; - } catch (MalformedURLException e) { - return existing; - } catch (URISyntaxException e) { - return existing; - } - } - - /** * Used with {@link #bodyForm(Form)}. */ public final static class Form { diff --git a/launcher/src/main/java/com/skcraft/launcher/util/HttpRequest.java b/launcher/src/main/java/com/skcraft/launcher/util/HttpRequest.java index 2f334bd..f8b2dcc 100644 --- a/launcher/src/main/java/com/skcraft/launcher/util/HttpRequest.java +++ b/launcher/src/main/java/com/skcraft/launcher/util/HttpRequest.java @@ -17,7 +17,10 @@ import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import java.io.*; -import java.net.*; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; import java.util.*; import static com.skcraft.launcher.LauncherUtils.checkInterrupted; @@ -132,7 +135,7 @@ throw new IOException("Too many redirects!"); } - HttpURLConnection conn = (HttpURLConnection) reformat(url).openConnection(); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Java) SKMCLauncher"); conn.setInstanceFollowRedirects(false); @@ -174,7 +177,6 @@ case 307: case 308: String location = conn.getHeaderField("Location"); - location = URLDecoder.decode(location, "UTF-8"); redirectCount++; return runRequest(new URL(this.url, location)); @@ -434,29 +436,6 @@ } /** - * URL may contain spaces and other nasties that will cause a failure. - * - * @param existing the existing URL to transform - * @return the new URL, or old one if there was a failure - */ - private static URL reformat(URL existing) { - try { - URL url = new URL(existing.toString()); - URI uri = new URI( - url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), - url.getPath(), url.getQuery(), url.getRef()); - url = uri.toURL(); - return url; - } catch (MalformedURLException e) { - log.warning("Failed to reformat url " + existing.toString() + ", using unformatted version."); - return existing; - } catch (URISyntaxException e) { - log.warning("Failed to reformat url " + existing.toString() + ", using unformatted version."); - return existing; - } - } - - /** * Used with {@link #bodyForm(Form)}. */ public final static class Form {