You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by jongraf <Jo...@hbo.com> on 2009/11/10 16:18:32 UTC

Using @CookieParam to retrieve a cookie only returns the last cookie

Hello all,

While attempting to use @CookieParam to get a cookie where many cookies
exist, I discovered that it does not matter what cookie name is requested. 
As long as cookies exist in the HTTP Request, the last cookie in the
collection of cookies will be returned.

Problem class: org.apache.cxf.jaxrs.utils.JAXRSUtils

In JAXRSUtils.processCookieParam(), if there are multiple cookies in the
header, only the last cookie will be returned when Cookie.valueOf() is
called.

This is because the list of all cookies is returned from values.get(0). 
When Cookie.valueOf() is called, it delegates to CookieHeaderProvider which
simply loops through all of the tokenized cookie values and returns the last
cookie.

I have opened CXF-2529 to track this.

Has anyone else encountered this or successfully used @CookieParam?

Jonathan
-- 
View this message in context: http://old.nabble.com/Using-%40CookieParam-to-retrieve-a-cookie-only-returns-the-last-cookie-tp26284850p26284850.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Using @CookieParam to retrieve a cookie only returns the last cookie

Posted by Sergey Beryozkin <sb...@progress.com>.
Done

It took me a bit of time to merge to 2.2.x

thanks, Sergey
----- Original Message ----- 
From: "jongraf" <Jo...@hbo.com>
To: <us...@cxf.apache.org>
Sent: Tuesday, November 10, 2009 3:49 PM
Subject: Re: Using @CookieParam to retrieve a cookie only returns the last cookie


>
> That's great Sergey.  Thank you for the quick update.  I assume you'll be
> assigning a fix version to the JIRA issue?
>
>
> Sergey Beryozkin-2 wrote:
>>
>> Hi
>>
>> The fix has just been committed, I did at at lunch time but thought of
>> committing in the evening :-)
>> There're few workarounds at the moment but the simplest is to do
>>
>> @HttpHeader("Cookie") List<Cookie> cookies
>>
>> thanks, Sergey
>>
>> ----- Original Message ----- 
>> From: "jongraf" <Jo...@hbo.com>
>> To: <us...@cxf.apache.org>
>> Sent: Tuesday, November 10, 2009 3:18 PM
>> Subject: Using @CookieParam to retrieve a cookie only returns the last
>> cookie
>>
>>
>>>
>>> Hello all,
>>>
>>> While attempting to use @CookieParam to get a cookie where many cookies
>>> exist, I discovered that it does not matter what cookie name is
>>> requested.
>>> As long as cookies exist in the HTTP Request, the last cookie in the
>>> collection of cookies will be returned.
>>>
>>> Problem class: org.apache.cxf.jaxrs.utils.JAXRSUtils
>>>
>>> In JAXRSUtils.processCookieParam(), if there are multiple cookies in the
>>> header, only the last cookie will be returned when Cookie.valueOf() is
>>> called.
>>>
>>> This is because the list of all cookies is returned from values.get(0).
>>> When Cookie.valueOf() is called, it delegates to CookieHeaderProvider
>>> which
>>> simply loops through all of the tokenized cookie values and returns the
>>> last
>>> cookie.
>>>
>>> I have opened CXF-2529 to track this.
>>>
>>> Has anyone else encountered this or successfully used @CookieParam?
>>>
>>> Jonathan
>>> -- 
>>> View this message in context:
>>> http://old.nabble.com/Using-%40CookieParam-to-retrieve-a-cookie-only-returns-the-last-cookie-tp26284850p26284850.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
> -- 
> View this message in context: 
> http://old.nabble.com/Using-%40CookieParam-to-retrieve-a-cookie-only-returns-the-last-cookie-tp26284850p26285761.html
> Sent from the cxf-user mailing list archive at Nabble.com.
> 


Re: Using @CookieParam to retrieve a cookie only returns the last cookie

Posted by jongraf <Jo...@hbo.com>.
That's great Sergey.  Thank you for the quick update.  I assume you'll be
assigning a fix version to the JIRA issue?


Sergey Beryozkin-2 wrote:
> 
> Hi
> 
> The fix has just been committed, I did at at lunch time but thought of
> committing in the evening :-)
> There're few workarounds at the moment but the simplest is to do
> 
> @HttpHeader("Cookie") List<Cookie> cookies
> 
> thanks, Sergey
> 
> ----- Original Message ----- 
> From: "jongraf" <Jo...@hbo.com>
> To: <us...@cxf.apache.org>
> Sent: Tuesday, November 10, 2009 3:18 PM
> Subject: Using @CookieParam to retrieve a cookie only returns the last
> cookie
> 
> 
>>
>> Hello all,
>>
>> While attempting to use @CookieParam to get a cookie where many cookies
>> exist, I discovered that it does not matter what cookie name is
>> requested.
>> As long as cookies exist in the HTTP Request, the last cookie in the
>> collection of cookies will be returned.
>>
>> Problem class: org.apache.cxf.jaxrs.utils.JAXRSUtils
>>
>> In JAXRSUtils.processCookieParam(), if there are multiple cookies in the
>> header, only the last cookie will be returned when Cookie.valueOf() is
>> called.
>>
>> This is because the list of all cookies is returned from values.get(0).
>> When Cookie.valueOf() is called, it delegates to CookieHeaderProvider
>> which
>> simply loops through all of the tokenized cookie values and returns the
>> last
>> cookie.
>>
>> I have opened CXF-2529 to track this.
>>
>> Has anyone else encountered this or successfully used @CookieParam?
>>
>> Jonathan
>> -- 
>> View this message in context: 
>> http://old.nabble.com/Using-%40CookieParam-to-retrieve-a-cookie-only-returns-the-last-cookie-tp26284850p26284850.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/Using-%40CookieParam-to-retrieve-a-cookie-only-returns-the-last-cookie-tp26284850p26285761.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Using @CookieParam to retrieve a cookie only returns the last cookie

Posted by Sergey Beryozkin <sb...@progress.com>.
Hi

The fix has just been committed, I did at at lunch time but thought of committing in the evening :-)
There're few workarounds at the moment but the simplest is to do

@HttpHeader("Cookie") List<Cookie> cookies

thanks, Sergey

----- Original Message ----- 
From: "jongraf" <Jo...@hbo.com>
To: <us...@cxf.apache.org>
Sent: Tuesday, November 10, 2009 3:18 PM
Subject: Using @CookieParam to retrieve a cookie only returns the last cookie


>
> Hello all,
>
> While attempting to use @CookieParam to get a cookie where many cookies
> exist, I discovered that it does not matter what cookie name is requested.
> As long as cookies exist in the HTTP Request, the last cookie in the
> collection of cookies will be returned.
>
> Problem class: org.apache.cxf.jaxrs.utils.JAXRSUtils
>
> In JAXRSUtils.processCookieParam(), if there are multiple cookies in the
> header, only the last cookie will be returned when Cookie.valueOf() is
> called.
>
> This is because the list of all cookies is returned from values.get(0).
> When Cookie.valueOf() is called, it delegates to CookieHeaderProvider which
> simply loops through all of the tokenized cookie values and returns the last
> cookie.
>
> I have opened CXF-2529 to track this.
>
> Has anyone else encountered this or successfully used @CookieParam?
>
> Jonathan
> -- 
> View this message in context: 
> http://old.nabble.com/Using-%40CookieParam-to-retrieve-a-cookie-only-returns-the-last-cookie-tp26284850p26284850.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>