Discussion:
Jersey client and chunked encoding vs. Content-Length
Ryan Stewart
2012-01-18 19:08:32 UTC
Permalink
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?
youngl
2012-01-26 04:30:08 UTC
Permalink
Hi,

I recently went through a similiar experience. I found that if u set the
Content-Type to application/octet-stream, then the Jersey MessageWriter for
the application/octet-stream will set the Content-Length and
not send as chunked transport method.


--
View this message in context: http://jersey.576304.n2.nabble.com/Jersey-client-and-chunked-encoding-vs-Content-Length-tp7201395p7225976.html
Sent from the Jersey mailing list archive at Nabble.com.

Loading...