0

I have a HttpEntity I received from a web server. If I check that HttpEntity with getContentLength() it shows a value > 0. So there seems to be content. I run getContent() to get an InputStream and on that InputStream I run read() to get the content. On the first read() operation it throws an IO Exception that the stream is closed "Attempted read on closed stream.".

My Code is:

HttpEntity myEntity = myResponse.getEntity();
InputStream inputStream = myEntity.getContent();
inputStream.read();

So I am not calling close() on that stream. I cannot rule out that something is wrong with the HttpEntity, looking at myEntity in the debugger I see (no idea if that helps):

is1=EofSensorInputStream
eofWatcher=BasicManagedEntity
selfClosed=true
wrappedStream=null

getContentLength() on the InputStream shows the value as on the HttpEntity.

I have no clue where to start looking to figure out the issue. What can I check to find the issue?

AndyAndroid
  • 4,039
  • 14
  • 44
  • 71

1 Answers1

-1

Please refer to this link which says REPEATABLE entities can use getContent() and writeTo(OutputStream) procedures only once.

To know if your entity is REPEATABLE, use isRepeatable().

VP.
  • 15,509
  • 17
  • 91
  • 161