users@jersey.java.net

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

From: Arul Dhesiaseelan <aruld_at_acm.org>
Date: Sat, 8 Feb 2014 14:52:40 -1000

This is implemented in 2.5 (https://java.net/jira/browse/JERSEY-2224). You
could use
https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/client/RequestEntityProcessing.html#BUFFEREDto
stream your content. Here is an example using ApacheConnector:
https://github.com/aruld/sof-18157218/blob/master/src/test/java/info/aruld/jersey/EntityStreamingTest.java

- Arul


On Thu, Jan 30, 2014 at 1:45 AM, Will Ferguson <willferguson00_at_gmail.com>wrote:

> Have done now - thanks,
>
> https://java.net/jira/browse/JERSEY-2373
>
>
>
>
> On 28 January 2014 15:28, cowwoc <cowwoc_at_bbs.darktech.org> wrote:
>
>> ... 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>
>> Reply-To: "users_at_jersey.java.net" <users_at_jersey.java.net>
>> Date: Monday, January 27, 2014 3:11 AM
>> To: "users_at_jersey.java.net" <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> 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
>> w: www.northplains.com
>> Blog: http://www.northplains.com/blog/
>> Twitter: https://twitter.com/northplains
>>
>>
>>
>




picture
(image/png attachment: 01-part)