I am getting an exception while trying to get the content from a
HttpResponse.

Code:

String message = IOUtils.toString(response.getEntity().getContent());
... // Do Something with InputStream

EntityUtils.close(response.getEntity());

In EntityUtils class close method; I get an IOException at line 65

// Line 65
InputStream instream = entity.getContent();

The exception is java.io.IOException: Attempted read from closed stream.

Further debugging; I found that when the response encoding uses gzip
("Content-Encoding: gzip"); I get this error. So basically if its a
BasicHttpEntity instead of GzipDecompressingEntity it works fine. Otherwise
this exception is thrown.

Appreciate any inputs into this.

Thanks,
Srinivas

Reply via email to