2005-03-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 31 Mar 2005 02:32:49 +0000 (02:32 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 31 Mar 2005 02:32:49 +0000 (02:32 -0000)
* CookieContainer.cs: adding to a CookieCollection might not increment
the number of items if the cookie is replaced. Now Count works properly.
Fixed an array index exception (typo).

* CookieCollection.cs: also compare the version.

* HttpWebResponse.cs: when we have cookies, add them to the request
container.

* HttpWebRequest.cs: changed last parameter of HttpWebResponse ctor.

svn path=/trunk/mcs/; revision=42411

mcs/class/System/System.Net/ChangeLog
mcs/class/System/System.Net/CookieCollection.cs
mcs/class/System/System.Net/CookieContainer.cs
mcs/class/System/System.Net/HttpWebRequest.cs
mcs/class/System/System.Net/HttpWebResponse.cs

index 602b73077637e7c67728a4ca3aec5a51bb62db76..90c499664b52d05c5017c2d72a664c6ef08eafbc 100644 (file)
@@ -1,3 +1,16 @@
+2005-03-30 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * CookieContainer.cs: adding to a CookieCollection might not increment
+       the number of items if the cookie is replaced. Now Count works properly.
+       Fixed an array index exception (typo).
+
+       * CookieCollection.cs: also compare the version.
+
+       * HttpWebResponse.cs: when we have cookies, add them to the request
+       container.
+
+       * HttpWebRequest.cs: changed last parameter of HttpWebResponse ctor.
+
 2005-03-30  Miguel de Icaza  <miguel@novell.com>
 
        * Cookie.cs: Compare using the InvariantCulture, to match the
index 3a123ef11d268b9d9044f310050d296a182064f6..6752230648890b4baab15c1ec905d1ef58c7fe89 100644 (file)
@@ -82,7 +82,7 @@ namespace System.Net
                        int pos = SearchCookie (cookie);
                        if (pos == -1)
                                list.Add (cookie);
-                       else 
+                       else
                                list [pos] = cookie;
                }
 
@@ -94,6 +94,9 @@ namespace System.Net
 
                        for (int i = list.Count - 1; i >= 0; i--) {
                                Cookie c = (Cookie) list [i];
+                               if (c.Version != cookie.Version)
+                                       continue;
+
                                if (0 != String.Compare (domain, c.Domain, true, CultureInfo.InvariantCulture))
                                        continue;
 
index c6ba21ad05ae09de2ce7a57973892000eaa78b5a..0ee5678ea21ffb6b06e80987746287ca6b8ad641 100644 (file)
@@ -140,7 +140,7 @@ namespace System.Net
                                        throw new CookieException ("Capacity exceeded");
 
                                cookies.Add (cookie);
-                               count++;
+                               count = cookies.Count;
                        }
                }
 
@@ -265,7 +265,7 @@ namespace System.Net
                                                        continue;
 
                                                if (path [path.Length - 1] != '/' && uripath.Length > path.Length &&
-                                                   path [path.Length] != '/')
+                                                   uripath [path.Length] != '/')
                                                        continue;
                                        }
                                }
index d577bf05a17e66122fd2e467b29a1762bdfd835a..2e007c36ce1d58ba2a69fd571b06eb31484a030c 100644 (file)
@@ -1023,7 +1023,7 @@ namespace System.Net
 
                        WebException wexc = null;
                        try {
-                               webResponse = new HttpWebResponse (actualUri, method, data, (cookieContainer != null));
+                               webResponse = new HttpWebResponse (actualUri, method, data, cookieContainer);
                                haveResponse = true;
                        } catch (Exception e) {
                                wexc = new WebException (e.Message, e, WebExceptionStatus.ProtocolError, null); 
index 8f691e6f0996469559293d7e25b61907d4d47a91..4868bd1caa9eb7e362032b78d4da07515d098166 100644 (file)
@@ -52,13 +52,14 @@ namespace System.Net
                string statusDescription;
                long contentLength = -1;
                string contentType;
+               CookieContainer cookieContainer;
 
                bool disposed = false;
                Stream stream;
                
                // Constructors
                
-               internal HttpWebResponse (Uri uri, string method, WebConnectionData data, bool cookiesSet)
+               internal HttpWebResponse (Uri uri, string method, WebConnectionData data, CookieContainer container)
                {
                        this.uri = uri;
                        this.method = method;
@@ -67,7 +68,8 @@ namespace System.Net
                        statusCode = (HttpStatusCode) data.StatusCode;
                        statusDescription = data.StatusDescription;
                        stream = data.stream;
-                       if (cookiesSet) {
+                       if (container != null) {
+                               this.cookieContainer = container;
                                FillCookies ();
                        } else if (webHeaders != null) {
                                webHeaders.RemoveInternal ("Set-Cookie");
@@ -408,6 +410,8 @@ namespace System.Net
                                cookie.Domain = uri.Host;
 
                        cookieCollection.Add (cookie);
+                       if (cookieContainer != null)
+                               cookieContainer.Add (uri, cookie);
                }
 
                void SetCookie2 (string cookies_str)