[Mono-dev] Patch for CookieContainer.SetCookies

Sebastien Pouliot sebastien.pouliot at gmail.com
Wed Jan 20 16:36:08 EST 2010

Hello Tom,

On Mon, 2010-01-18 at 15:31 -0800, Tom Philpot wrote:
> 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.

Tests run: 5665, Failures: 2, Not run: 30, Time: 93.143 seconds

Test Case Failures:
1) MonoTests.System.Net.CookieContainerTest.SaveAndLoadViaSetCookies :
  Expected: 2015-01-01 05:00:00.000
  But was:  2015-01-01 08:00:00.000

at MonoTests.System.Net.CookieContainerTest.SaveAndLoadViaSetCookies ()
in /home/poupou/svn/mcs/class/System/Test/System.Net/CookieContainerTest.cs:1624
at (wrapper managed-to-native)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture) [0x000ca]
in /home/poupou/svn/mcs/class/corlib/System.Reflection/MonoMethod.cs:212

I get the above error while testing your patch on HEAD. Please fix the
test and re-issue your patch with the correct coding convention.


More information about the Mono-devel-list mailing list