users@jersey.java.net

Re: [Jersey] client: Transfer-Encoding chunked handling

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 16 Jul 2009 09:21:41 +0200

On Jul 15, 2009, at 8:49 PM, Bill de hOra wrote:

> Hi,
>
> does anyone know if jersey client handle Transfer-Encoding: chunked
> responses under the hood, or is it expected you deal with this via
> your own streams?
>

Chunked transfer encoding is supported.

The default configuration for the Client is to use HttpURLConnection
and it will use the default settings of that for transfer encoding.
The default is that the client will not send a request entity using
the chunked encoding (because resending is supported by default e.g.
for authentication or redirection).

You need to set the following property:

https://jersey.dev.java.net/nonav/apidocs/1.1.1-ea/jersey/com/sun/jersey/api/client/Client.html
#setChunkedEncodingSize(java.lang.Integer)

which will disable redirection.

Note that i have encountered some issues with HttpURLConnection and
chunked encoding of requests (sorry i cannot recall the exact
details). If you hit those you may want to switch to using the Jersey
client with the Apache HTTP client.

Paul.