diff options
author | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-09 13:23:57 +0900 |
---|---|---|
committer | syeyoung <42869671+cyoung06@users.noreply.github.com> | 2020-12-09 13:23:57 +0900 |
commit | e3a6c36154d5336e72e5be014c27ce5148f10487 (patch) | |
tree | 7915ce87eee3203c50e8fd369a34bf261ffd0ef3 | |
parent | 9b70470c5c7c2e47fca1bd4e066b478616487be0 (diff) | |
download | Skyblock-Dungeons-Guide-e3a6c36154d5336e72e5be014c27ce5148f10487.tar.gz Skyblock-Dungeons-Guide-e3a6c36154d5336e72e5be014c27ce5148f10487.tar.bz2 Skyblock-Dungeons-Guide-e3a6c36154d5336e72e5be014c27ce5148f10487.zip |
more hacky stuff asd
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/customurl/DGURLConnection.java | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/customurl/DGURLConnection.java b/src/main/java/kr/syeyoung/dungeonsguide/customurl/DGURLConnection.java index 6a97d96a..1469a064 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/customurl/DGURLConnection.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/customurl/DGURLConnection.java @@ -15,7 +15,7 @@ import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; -public class DGURLConnection extends URLConnection { +public class DGURLConnection extends HttpURLConnection { private static final String DOMAIN = "http://localhost:8080/"; private Authenticator authenticator; @@ -25,11 +25,6 @@ public class DGURLConnection extends URLConnection { this.authenticator = authenticator; } - @Override - public void setUseCaches(boolean b) { - checkExist = !b; - } - private boolean checkExist = false; private boolean exists= false; @Override @@ -51,14 +46,14 @@ public class DGURLConnection extends URLConnection { HttpURLConnection huc = (HttpURLConnection) new URL(DOMAIN + "resource/resource?class=" + URLEncoder.encode(url.getPath().substring(1))).openConnection(); huc.setRequestProperty("User-Agent", "DungeonsGuide/1.0"); huc.setRequestProperty("Content-Type", "application/json"); - huc.setRequestMethod(checkExist ? "HEAD" : "GET"); + huc.setRequestMethod(method.equals("HEAD") ? "HEAD" : "GET"); huc.setRequestProperty("Authorization", (url.getUserInfo() == null && classLoader) ? authenticator.getToken() : url.getUserInfo()); huc.setDoInput(true); huc.setDoOutput(true); - System.out.println("Resp Code::" + huc.getResponseCode() + "/ " + checkExist); + System.out.println("Resp Code::" + huc.getResponseCode() + "/ " + method); exists = huc.getResponseCode() != 404; - if (checkExist) { + if (method.equals("HEAD")) { return; } @@ -116,7 +111,16 @@ public class DGURLConnection extends URLConnection { @Override public InputStream getInputStream() throws IOException { if (!connected) connect(); - if (checkExist && !exists) throw new FileNotFoundException(); + if (method.equals("HEAD") && !exists) throw new FileNotFoundException(); return inputStream; } + + @Override + public void disconnect() { + } + + @Override + public boolean usingProxy() { + return false; + } } |