users@jersey.java.net

[Jersey] Jersey client and chunked encoding vs. Content-Length

From: Ryan Stewart <rds6235_at_gmail.com>
Date: Wed, 18 Jan 2012 13:08:32 -0600

I'm using the Jersey client to talk to someone else's restful service, and
I hit a snag, which I believe is actually a bug in their service, but I
need to try to work around it in case they can't/won't fix it. Using the
ApacheHttpClient4, when I POST an entity, it uses chunked encoding by
default. The service I'm talking to is giving me a "411 Length Required" in
response, though it claims to be HTTP/1.1. The API docs at
Client.setChunkedEncodingSize()<http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/client/Client.html#setChunkedEncodingSize%28java.lang.Integer%29>seem
to imply that sending null to that method will turn off chunked
encoding, but that's not working. The value it sets doesn't even seem to be
queried when using the ApacheHttpClient4. It seems to only apply if you're
using the default
URLConnectionClientHandler<http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/client/urlconnection/URLConnectionClientHandler.html>
.

Is there a way to turn of chunked transfers with the Apache client?