(String url, T postString, HashMap<String, ?> headers, String encoding)
| 97 | // } |
| 98 | |
| 99 | public static <T> Response post(String url, T postString, HashMap<String, ?> headers, String encoding) { |
| 100 | Response response = new Response(0, (String)null, (String)null, (String)null); |
| 101 | |
| 102 | try { |
| 103 | HttpURLConnection conn = getCoon(url); |
| 104 | conn.setRequestMethod("POST"); |
| 105 | Iterator var5 = headers.keySet().iterator(); |
| 106 | |
| 107 | while(var5.hasNext()) { |
| 108 | String key = (String)var5.next(); |
| 109 | conn.setRequestProperty(key, (String)headers.get(key)); |
| 110 | } |
| 111 | |
| 112 | OutputStream outputStream = conn.getOutputStream(); |
| 113 | if (postString instanceof String){ |
| 114 | outputStream.write(((String) postString).getBytes()); |
| 115 | }else { |
| 116 | outputStream.write((byte[]) postString); |
| 117 | } |
| 118 | outputStream.flush(); |
| 119 | outputStream.close(); |
| 120 | response = getResponse(conn, encoding); |
| 121 | } catch (Exception var8) { |
| 122 | LOGGER.debug(var8.getMessage()); |
| 123 | response.setError(var8.getMessage()); |
| 124 | } |
| 125 | |
| 126 | return response; |
| 127 | } |
| 128 | |
| 129 | private static Response getResponse(HttpURLConnection conn, String encoding) { |
| 130 | Response response = new Response(0, (String)null, (String)null, (String)null); |
no test coverage detected