users@jersey.java.net

[Jersey] Re: ApacheConnector & setting Content-Length header (Jeysey Client 2.4.1)

From: cowwoc <cowwoc_at_bbs.darktech.org>
Date: Tue, 28 Jan 2014 10:28:09 -0500

... shouldn't this be fixed in Jersey proper so users don't need to keep
on doing this? Did anyone file a bug report?

Gili

On 28/01/2014 5:03 AM, Will wrote:
> Thanks Todd, was hoping I didn't have to do that but looks like the
> only way.
>
> On 01/27/2014 06:17 PM, Todd Donahue wrote:
>> I had the same problem, and wrote my own connector based on the
>> existing ApacheConnector. See the following SO article for more details:
>>
>> http://stackoverflow.com/questions/18157218/jersey-2-0-content-length-not-set
>>
>> Make sure you understand that a copy of the entity will be made and
>> for large entity bodies this may cause an out of memory problem. My
>> requests were known to have small entity bodies, so this method works
>> well for me.
>>
>> --
>> Todd
>>
>> From: Will Ferguson <willferguson00_at_gmail.com
>> <mailto:willferguson00_at_gmail.com>>
>> Reply-To: "users_at_jersey.java.net <mailto:users_at_jersey.java.net>"
>> <users_at_jersey.java.net <mailto:users_at_jersey.java.net>>
>> Date: Monday, January 27, 2014 3:11 AM
>> To: "users_at_jersey.java.net <mailto:users_at_jersey.java.net>"
>> <users_at_jersey.java.net <mailto:users_at_jersey.java.net>>
>> Subject: [Jersey] Re: ApacheConnector & setting Content-Length header
>> (Jeysey Client 2.4.1)
>>
>> Hi All,
>>
>> Am I right to assume then that setting the content-length just isn't
>> possible with the ApacheConnector?
>>
>> If anyone has any idea about this would be great,
>>
>> Thanks,
>>
>> Will
>>
>>
>> On 13 January 2014 09:58, Will Ferguson <willferguson00_at_gmail.com
>> <mailto:willferguson00_at_gmail.com>> wrote:
>>
>> Hi,
>>
>> Could anyone please explain how get Jersey / ApacheConnector to
>> set the correct Content-Length header on a client request?
>>
>> I have a REST service that requires this be set to the size of
>> the entity in a PUT request, and I can't work out how to enable it.
>>
>> It seems calculating it in the MessageBodyWriter has been
>> deprecated and it looks like the ApacheConnector is always
>> setting it to -1.
>>
>> Thanks in advance,
>>
>> Will
>>
>>
>
> --
> *Will Ferguson*
> Senior Software Engineer
> Zetland House, 5-25 Scrutton Street
> London, EC2A 4HJ, UK
> p: +44 (0)207 749 1800
> e: wferguson_at_northplains.com <mailto:wferguson_at_northplains.com>
> w: www.northplains.com <http://www.northplains.com/>
> Blog: http://www.northplains.com/blog/ <http://www.northplains.com/blog>
> Twitter: https://twitter.com/northplains