[Mono-bugs] [Bug 81421][Nor] New - CookieContainer: GetCookies adds cookie in wrong order

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Apr 22 05:26:32 EDT 2007

Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by steveb at mindtouch.com.


--- shadow/81421	2007-04-22 05:26:32.000000000 -0400
+++ shadow/81421.tmp.13359	2007-04-22 05:26:32.000000000 -0400
@@ -0,0 +1,60 @@
+Bug#: 81421
+Product: Mono: Class Libraries
+Version: 1.2
+OS: other
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: Sys.Web
+AssignedTo: mhabersack at novell.com                            
+ReportedBy: steveb at mindtouch.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+Summary: CookieContainer: GetCookies adds cookie in wrong order
+Description of Problem:
+When retrieving the cookies for a Uri, the cookies are added in the wrong
+order.  They are added from least specific (shortest matching uri path) to
+most specific (longest matching uri path), but should instead be listed
+from most specific to least specific.  This is important when cookies have
+the same name, as currently the least specific one is listed first, it will
+shadow the more specific one.  .Net adds cookies in the correct order.  See
+sample below.
+using System;
+using System.Net;
+namespace CookieTest {
+    class Program {
+        static void Main(string[] args) {
+            CookieContainer container = new CookieContainer();
+            container.Add(new Cookie("name", "value1", "/path", "localhost"));
+            container.Add(new Cookie("name", "value2", "/path/sub",
+            CookieCollection cookies = container.GetCookies(new
+            foreach(Cookie c in cookies) {
+                Console.WriteLine("{0}=\"{1}\"; path=\"{2}\";
+domain=\"{3}\"", c.Name, c.Value, c.Path, c.Domain);
+            }
+        }
+    }
+Actual Results (as seen on mono):
+name="value1"; path="/path"; domain="localhost"
+name="value2"; path="/path/sub"; domain="localhost"
+Expected Results (as seen on .Net):
+name="value2"; path="/path/sub"; domain="localhost"
+name="value1"; path="/path"; domain="localhost"
+How often does this happen? 
+All the time.

More information about the mono-bugs mailing list