I'm having a strange problem with using InputStreamEntity for a POST
operation.
If I use a StringEntity the operation works fine.
If I use an InputStreamEntity based on the same content then no content
gets POSTed.
Any ideas why?
Example would be like this:
String source = "hello";
InputStream content = new ByteArrayInputStream(source.getBytes());
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(uri);
httpPost.setEntity(new StringEntity(source)); // this works
//httpPost.setEntity(new InputStreamEntity(content)); // this doesn't
try (CloseableHttpResponse response = httpclient.execute(httpPost)) {
System.out.println(response.getStatusLine().toString()); //
gives a 200 either way
HttpEntity entity = response.getEntity();
String result = EntityUtils.toString(entity);
System.out.println("Result: " + result);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org