+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
int pos = SearchCookie (cookie);
if (pos == -1)
list.Add (cookie);
- else
+ else
list [pos] = cookie;
}
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;
throw new CookieException ("Capacity exceeded");
cookies.Add (cookie);
- count++;
+ count = cookies.Count;
}
}
continue;
if (path [path.Length - 1] != '/' && uripath.Length > path.Length &&
- path [path.Length] != '/')
+ uripath [path.Length] != '/')
continue;
}
}
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);
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;
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");
cookie.Domain = uri.Host;
cookieCollection.Add (cookie);
+ if (cookieContainer != null)
+ cookieContainer.Add (uri, cookie);
}
void SetCookie2 (string cookies_str)