(String urlStr, Map headers, byte[] content)
| 76 | } |
| 77 | |
| 78 | public static String post(String urlStr, Map headers, byte[] content) throws IOException |
| 79 | { |
| 80 | HttpURLConnection httpurlconnection = null; |
| 81 | String s3; |
| 82 | |
| 83 | try |
| 84 | { |
| 85 | URL url = new URL(urlStr); |
| 86 | httpurlconnection = (HttpURLConnection)url.openConnection(Minecraft.getMinecraft().getProxy()); |
| 87 | httpurlconnection.setRequestMethod("POST"); |
| 88 | |
| 89 | if (headers != null) |
| 90 | { |
| 91 | for (Object s : headers.keySet()) |
| 92 | { |
| 93 | String s1 = "" + headers.get(s); |
| 94 | httpurlconnection.setRequestProperty((String) s, s1); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | httpurlconnection.setRequestProperty("Content-Type", "text/plain"); |
| 99 | httpurlconnection.setRequestProperty("Content-Length", "" + content.length); |
| 100 | httpurlconnection.setRequestProperty("Content-Language", "en-US"); |
| 101 | httpurlconnection.setUseCaches(false); |
| 102 | httpurlconnection.setDoInput(true); |
| 103 | httpurlconnection.setDoOutput(true); |
| 104 | OutputStream outputstream = httpurlconnection.getOutputStream(); |
| 105 | outputstream.write(content); |
| 106 | outputstream.flush(); |
| 107 | outputstream.close(); |
| 108 | InputStream inputstream = httpurlconnection.getInputStream(); |
| 109 | InputStreamReader inputstreamreader = new InputStreamReader(inputstream, "ASCII"); |
| 110 | BufferedReader bufferedreader = new BufferedReader(inputstreamreader); |
| 111 | StringBuffer stringbuffer = new StringBuffer(); |
| 112 | String s2; |
| 113 | |
| 114 | while ((s2 = bufferedreader.readLine()) != null) |
| 115 | { |
| 116 | stringbuffer.append(s2); |
| 117 | stringbuffer.append('\r'); |
| 118 | } |
| 119 | |
| 120 | bufferedreader.close(); |
| 121 | s3 = stringbuffer.toString(); |
| 122 | } |
| 123 | finally |
| 124 | { |
| 125 | if (httpurlconnection != null) |
| 126 | { |
| 127 | httpurlconnection.disconnect(); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return s3; |
| 132 | } |
| 133 | |
| 134 | public static synchronized String getPlayerItemsUrl() |
| 135 | { |
no test coverage detected