You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by "Hankin, Keith" <kh...@amazon.com> on 2006/02/08 01:47:09 UTC

Connection gets closed on GET operation

I'm doing a very simple GET operation using regular (non-SSL) http access. I
call the Method.getResponseBodyAsStream() method and do a couple of reads to read a few bytes.
My third read fails with exception "java.io.IOException: Attempted read on closed
stream", yet I have not closed the stream.

I'm noting that the connection is of
class org.apache.commons.httpclient.AutoCloseInputStream, so maybe it's self
closing? I've looked at the code for this class and it says that it closes the
Connection when no more content, but I have only read the first couple of bytes of data.

-Keith


Re: Connection gets closed on GET operation

Posted by Roland Weber <RO...@de.ibm.com>.
Hi Keith,

> I'm doing a very simple GET operation using regular (non-SSL) http 
access. I
> call the Method.getResponseBodyAsStream() method and do a couple of 
> reads to read a few bytes.
> My third read fails with exception "java.io.IOException: Attempted 
> read on closed
> stream", yet I have not closed the stream.

The stream is connecting your client to a server. It can be closed by your
application reading to EOF, by your application releasing the connection
you used for executing the GET method, or by the server. You have to 
provide
more specific information about what you are doing if you want us to help.

cheers,
  Roland

> 
> I'm noting that the connection is of
> class org.apache.commons.httpclient.AutoCloseInputStream, so maybe it's 
self
> closing? I've looked at the code for this class and it says that it 
closes the
> Connection when no more content, but I have only read the first 
> couple of bytes of data.
> 
> -Keith
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org