On 7/7/22 11:58, Gordon Ross wrote:
I’ve tried doing the bare minimum of:

InputStream is = response.getEntity().getContent();
is.close();
response.close();

I remember having some problems with connections staying open, leading the client to run out.  I was advised to make sure the entity is fully consumed.  Try this code instead of those three lines:

HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
is.close();
EntityUtils.consumeQuietly(entity);
response.close();

I am not in any way an expert or even very knowledgeable about httpclient, but this looks like what I ended up doing on advice from this list, which did fix my problem.  I can't find the code where I did this, so I can't verify.

https://hc.apache.org/httpcomponents-core-5.1.x/current/httpcore5/apidocs/org/apache/hc/core5/http/io/entity/EntityUtils.html#consumeQuietly(org.apache.hc.core5.http.HttpEntity)

Based on the javadoc, that might close the InputStream too, but someone who knows more than I do will have to confirm.

Thanks,
Shawn


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to