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 da...@attensity.com on 2010/12/13 18:38:02 UTC
No IOException when reading from ResponseBodyStream
Hi,
I'm using httpclient 3.1 and have the following problem:
After successfully sending a GET request I use getResponseBodyAsStream() to get access to the InputStream with the returned data (The server uses chunked transfer).
While reading from the InputStream the server sending the result crashes. It's still possible to read from the InputStream to some point (guess some data is buffered in the socket), but of course not all of the expected data. Reading from the InputStream stops because -1 is returned by read() which denotes EndOfStream. But this EndOfStream is not reached because all of the data was transferred but because the connection is lost. I would have expected that read() throws an IOException as the chunked transfer ended in the middle of communication. Is there any other way to find out that the EndOfStream was reached because of some internal problem ? Checking Content-Length is not an option because chunked transfer is used.
Bye,
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: AW: No IOException when reading from ResponseBodyStream
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2010-12-15 at 18:44 +0100, daniel.stucky@attensity.com wrote:
> Hi again,
>
> I just donwloaded HttpCore 4.1 and created a small test sample to
> reproduce the problem described in my former mail.
> When using the InputStream provided by HttpResponse
> getEntity().getContent() I get, as expected, an IOException (in our case
> a org.apache.http.TruncatedChunkException) if the server crashes during
> reading from the Stream.
>
> Is this a new feature introduced in HttpCore 4.x?
Yes, it is.
> Does HttpClient 3.1
> not provide these exceptions when using streams ?
>
Yes, it does not
Hope this helps
Oleg
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
AW: No IOException when reading from ResponseBodyStream
Posted by da...@attensity.com.
Hi again,
I just donwloaded HttpCore 4.1 and created a small test sample to
reproduce the problem described in my former mail.
When using the InputStream provided by HttpResponse
getEntity().getContent() I get, as expected, an IOException (in our case
a org.apache.http.TruncatedChunkException) if the server crashes during
reading from the Stream.
Is this a new feature introduced in HttpCore 4.x? Does HttpClient 3.1
not provide these exceptions when using streams ?
Bye,
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org