[mod_python] Cookie patch

Craig Warren craig.warren at encorp.com
Thu Jan 13 15:36:10 EST 2005


Nicolas Lehuen wrote:

>On Thu, 13 Jan 2005 12:44:36 -0700, Craig Warren
><craig.warren at encorp.com> wrote:
>  
>
>>Not quite sure this is correct above, I have a hard time
>>with the spec though..
>> 
>> But the problem I see is depending on the order of the value name pairs you
>>can get different results.
>> 
>> The first time though the loop will always put the l_key in the
>>all_cookies_attribute, then depending on the order, it will put the
>>attributes of the all_cookies_attribute on the next cookies
>> 
>> [cwarren at lapbob mod_python]$ python cookie_test.py
>> TEST
>>  --------------------------------------------------
>> New Funtion
>> Cookie:test=1;bob=1;$Version=0;$Path=/
>> Cookies
>> test=1
>> bob=1; version=0; path=/
>>  
>> My function Old with my fix
>> Cookie:test=1;bob=1;$Version=0;$Path=/
>> Cookies
>> test=1
>> bob=1; version=0; path=/
>>  
>>  --------------------------------------------------
>>  
>> TEST
>>  --------------------------------------------------
>> New Funtion
>> Cookie:$Version=0;$Path=/;test=1
>> Cookies
>> test=1; version=0; path=/
>>  
>> My function Old with my fix
>> Cookie:$Version=0;$Path=/;test=1
>> Cookies
>> $Version=0; version=0; path=/
>> test=1
>>  
>>  --------------------------------------------------
>>  
>> TEST
>>  --------------------------------------------------
>> New Funtion
>> Cookie:test=1;$Version=0;bob=1;$Path=/
>> Cookies
>> test=1; version=0
>> bob=1; path=/
>>  
>> My function Old with my fix
>> Cookie:test=1;$Version=0;bob=1;$Path=/
>> Cookies
>> test=1; version=0
>> bob=1; path=/
>>  
>>  --------------------------------------------------
>>  
>> [cwarren at lapbob mod_python]$
>> 
>> 
>> Maybe only set the "global" attributes to all cookies if it has a "$" in
>>front of it, so you would have to collect those the first time through the
>>loop then add them afterwards to each Cookie.  But like I said I don't quite
>>understand the spec very well.
>>    
>>
>[...]
>
>Well, the spec is pretty thin on the subject indeed, but what I
>understand is that the result MUST depend on the order in which the
>attributes are written. For example :
>
>Cookie: $Version=1;test=2;$Path=/
>==> a single Cookie with key=='test', value=='2' and attributes
>version=='1' and path=='/'
>
>Cookie: $Version=1;test1=2;$Path=/;test2=3;$Path=/foo
>==> two Cookies :
> - one with key=='test1', value=='2', version=='1' and path=='/'
> - one with key=='test2', value=='3', version=='1' and path=='/foo'
>
>Cookie: test1=2;$Path=/;$Version=1;test2=3;$Path=/foo;$Version=2
>==> two Cookies :
> - one with key=='test1', value=='2', version=='1' and path=='/'
> - one with key=='test2', value=='3', version=='2' and path=='/foo'
>
>Cookie: $Version=2;$Path='/fubar';test1=2;test2=3;$Path=/foo;$Version=1;test3=4;$Path=/bar;$Version=4
>==> three Cookies :
> - one with key=='test1', value=='2', version=='2' and path=='/fubar'
> - one with key=='test2', value=='3', version=='1' and path=='/foo'
> - one with key=='test3', value=='4', version=='4' and path=='/bar'
>
>To sum up, from what I understand, attributes are written like cookies
>whose name start by a dollar sign, and they apply to the rightmost
>preceding cookie.
>
>Attributes that are at the beginning of the Cookie header are 'global'
>attributes, used to describe the cookie 'baking' mechanism, like the
>Version attributes does. Here I chose to put those attributes in each
>Cookie, since I don't see any better way to return the information to
>the API user (maybe in a Cookies collection ?).
>
>I wrote a few tests and I checked that the new function does follow
>this interpretation of the RFC. The problem is that I'm not 100% sure
>that it's meant to be interpreted this way... I'll check in other
>Cookies implementations (in Python or Java) to make sure.
>
>Regards,
>Nicolas
>  
>
Sounds good. I will give your new function a try and let you know,  
Thanks for your work.

Craig

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20050113/adff53c9/attachment.html


More information about the Mod_python mailing list