MCPcopy Create free account
hub / github.com/DGVPSH/SlackOpen / get

Method get

src/main/java/net/optifine/http/HttpUtils.java:21–76  ·  view source on GitHub ↗
(String urlStr)

Source from the content-addressed store, hash-verified

19 public static final String POST_URL = "http://optifine.net";
20
21 public static byte[] get(String urlStr) throws IOException
22 {
23 HttpURLConnection httpurlconnection = null;
24 byte[] abyte1;
25
26 try
27 {
28 URL url = new URL(urlStr);
29 httpurlconnection = (HttpURLConnection)url.openConnection(Minecraft.getMinecraft().getProxy());
30 httpurlconnection.setDoInput(true);
31 httpurlconnection.setDoOutput(false);
32 httpurlconnection.connect();
33
34 if (httpurlconnection.getResponseCode() / 100 != 2)
35 {
36 if (httpurlconnection.getErrorStream() != null)
37 {
38 Config.readAll(httpurlconnection.getErrorStream());
39 }
40
41 throw new IOException("HTTP response: " + httpurlconnection.getResponseCode());
42 }
43
44 InputStream inputstream = httpurlconnection.getInputStream();
45 byte[] abyte = new byte[httpurlconnection.getContentLength()];
46 int i = 0;
47
48 while (true)
49 {
50 int j = inputstream.read(abyte, i, abyte.length - i);
51
52 if (j < 0)
53 {
54 throw new IOException("Input stream closed: " + urlStr);
55 }
56
57 i += j;
58
59 if (i >= abyte.length)
60 {
61 break;
62 }
63 }
64
65 abyte1 = abyte;
66 }
67 finally
68 {
69 if (httpurlconnection != null)
70 {
71 httpurlconnection.disconnect();
72 }
73 }
74
75 return abyte1;
76 }
77
78 public static String post(String urlStr, Map headers, byte[] content) throws IOException

Callers

nothing calls this directly

Calls 8

getMinecraftMethod · 0.95
readAllMethod · 0.95
openConnectionMethod · 0.80
disconnectMethod · 0.80
getInputStreamMethod · 0.65
getProxyMethod · 0.45
connectMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected