hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Cox <ben_cox...@hotmail.com>
Subject RE: HTTP Trailers in HttpClient 4.0.1
Date Wed, 03 Feb 2010 11:49:26 GMT

Oleg,

Thanks for your response. That's interesting - as you say, using trailers is somewhat of an
edge case, though there's something to be said for using them as part of mashup-type applications
in which data may be being sent over an extended period, so some state may be unknown at the
beginning of transmission.

I'd spotted the ChunkedInputStream before, but was unable to use it. Which InputStream are
you referring to? I tried casting entity.getContent(), but that's a ByteArrayInputStream,
and I can't find an InputStream for the response itself.

Thanks,
Ben


----------------------------------------
> Subject: Re: HTTP Trailers in HttpClient 4.0.1
> From: olegk@apache.org
> To: httpclient-users@hc.apache.org
> Date: Wed, 3 Feb 2010 11:41:25 +0100
>
> On Tue, 2010-02-02 at 21:07 +0000, Ben Cox wrote:
>> Hi all,
>>
>> I'm testing out using chunked encoding with trailing headers at the moment, but seem
to be having some problems getting the HttpClient to find the trailers. My code looks like
this:
>>
>> /***************************************************************/
>>
>> HttpClient httpClient = new DefaultHttpClient();
>> HttpGet httpGet = new HttpGet(url);
>>
>> // Tell the server that we can deal with trailers
>> httpGet.addHeader("TE", "trailers");
>>
>> // Get the response
>> HttpResponse response = httpClient.execute(httpGet);
>>
>> // Print out all the headers we have
>> for (Header aHeader : response.getAllHeaders()) {
>> System.out.println(aHeader.getName() + ": " + aHeader.getValue());
>> }
>>
>> /***************************************************************/
>>
>> The resultant document is transferred in around 100 chunks.
>>
>> I get all the other trailers I might expect to be printed, including the "Trailer:
Mytrailer" one that describes what trailers I should I expect. However, I don't get "Mytrailer"
at all, though I can see it on the wire if I use Wireshark.
>>
>> I noticed in the 3.x documentation there seems to be a lot more info about chunked
encoding and trailers/footers. However, there's not so much in the 4.0.1 documentation. Is
this not supported any more, or just more integrated into normal headers and I've got something
wrong?
>>
>> Any help is much appreciated.
>>
>> Thanks,
>> Ben
>>
>
> Hi Ben
>
> I personally have never seen trailers/footers used in any of the
> real-world application. This seems to be no convincing use case for
> them. This is the reason trailing headers in Httpclient 4.0 can only be
> accessed by casting the response InputStream to ChunkInputStream and
> calling ChunkInputStream#getFooters once the end of the stream has been
> reached.
>
> 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
>
 		 	   		  
_________________________________________________________________
Send us your Hotmail stories and be featured in our newsletter
http://clk.atdmt.com/UKM/go/195013117/direct/01/
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message