MCPcopy Create free account
hub / github.com/L1yp/van-app / POST

Method POST

src/main/java/com/l1yp/util/HttpTool.java:100–127  ·  view source on GitHub ↗
(String link, Map<String, String> headers, String body)

Source from the content-addressed store, hash-verified

98
99
100 public static Response POST(String link, Map<String, String> headers, String body) throws IOException {
101 URL url = new URL(link);
102 HttpURLConnection connection = (HttpURLConnection) url.openConnection();
103 connection.setRequestMethod("POST");
104
105 for (Entry<String, String> entry : headers.entrySet()) {
106 connection.setRequestProperty(entry.getKey(), entry.getValue());
107 }
108
109 connection.setUseCaches(false);
110
111 connection.setDoOutput(true);
112
113 connection.connect();
114 OutputStream os = connection.getOutputStream();
115 os.write(body.getBytes(StandardCharsets.UTF_8));
116 os.flush();
117 os.close();
118
119 Response response = new Response();
120 response.statusCode = connection.getResponseCode();
121 response.headers = connection.getHeaderFields();
122 response.body = connection.getInputStream().readAllBytes();
123
124 connection.getInputStream().close();
125
126 return response;
127 }
128
129
130 public static Response POST(String link, Map<String, String> headers, byte[] buffer, int pos, int size) throws IOException {

Callers

nothing calls this directly

Calls 2

getKeyMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected