Thanks for the link to the defect. I changed my code to use EntityUtils.toString(response.getEntity());
and removed the call to EntityUtils.close(response.getEntity()); When I enable debug logs; I can see that the toString method also returns the connection back to the connection manager. So I was left wondering if there is anything I am missing by not calling close? On Tue, Jun 14, 2011 at 4:27 AM, Oleg Kalnichevski <ol...@apache.org> wrote: > On Mon, 2011-06-13 at 14:38 -0400, Srinivas wrote: > > 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 > > Most likely this is the result of this defect > > https://issues.apache.org/jira/browse/HTTPCLIENT-1075 > > Oleg > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org > For additional commands, e-mail: httpclient-users-h...@hc.apache.org > >