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: [email protected]
For additional commands, e-mail: [email protected]