[Mono-dev] Patch for CookieContainer.SetCookies

Tom Philpot tom.philpot at logos.com
Mon Jan 18 18:31:37 EST 2010


The current implementation of CookieContainer.SetCookies does not handle the case where a cookie contains an "expires=..." attribute.

As documented on MSDN here: http://msdn.microsoft.com/en-us/library/aa384321%28VS.85%29.aspx the "Set-Cookie:" header expires attribute uses the following format: DAY, DD-MMM-YYYY HH:MM:SS GMT

The current version of SetCookies simply does a split on ',' in the header which totally causes the CookieContainer to choke when the expires attribute is set as MS recommends.

Also, the Add (Cookie) method of CookieContainer does not clone all the properties of the incoming cookie before adding it to the collection. Using SetCookies(Uri, string) should clone all the properties, so that is fixes as well in the patch and a test is added in the test cases.

I believe this makes the behavior of CookieContainer more "bug-compatible" with .NET.

Please review the patch and the test cases.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CookieContainerPatch.txt
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100118/3778125f/attachment-0004.txt 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ATT00001..txt
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100118/3778125f/attachment-0005.txt 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CookieContainerTest_Patch.txt
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100118/3778125f/attachment-0006.txt 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ATT00002..txt
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20100118/3778125f/attachment-0007.txt 


More information about the Mono-devel-list mailing list