Просмотр исходного кода

2005-03-30 Gonzalo Paniagua Javier <[email protected]>

	* 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
Gonzalo Paniagua Javier 21 лет назад
Родитель
Сommit
b5ce71c485

+ 13 - 0
mcs/class/System/System.Net/ChangeLog

@@ -1,3 +1,16 @@
+2005-03-30 Gonzalo Paniagua Javier <[email protected]>
+
+	* 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  <[email protected]>
 
 	* Cookie.cs: Compare using the InvariantCulture, to match the

+ 4 - 1
mcs/class/System/System.Net/CookieCollection.cs

@@ -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;
 

+ 2 - 2
mcs/class/System/System.Net/CookieContainer.cs

@@ -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;
 					}
 				}

+ 1 - 1
mcs/class/System/System.Net/HttpWebRequest.cs

@@ -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); 

+ 6 - 2
mcs/class/System/System.Net/HttpWebResponse.cs

@@ -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)