users@jersey.java.net

[Jersey] Re: Add cookie in ClientRequestFilter

From: Adam Lindenthal <adam.lindenthal_at_oracle.com>
Date: Fri, 6 Mar 2015 18:06:51 +0100

Hi Maarten,

I haven’t tried, but the JavaDoc claims, that getCookies() returns a read-only map. Brief looking into OutboundMessageContext.getRequestCookies() seems to confirm this, it returns new HashMap, so the reference is useless for adding a new cookie.
However, cookies from http point of view are just headers - and the ClientRequestContext.getHeaders() returns a mutable map of headers.
Without really trying it, this seems to me as a viable way.

Regards,
Adam

> On 03 Mar 2015, at 13:26, Maarten Boekhold <boekhold_at_gmx.com> wrote:
>
> Hi,
>
> Is there any way to add a Cookie to a ClientRequestContext inside a ClientRequestFilter?
>
> Maarten