This patch fixes a minor problem with HttpWebRequest not actually using
the Version property and HttpWebResponse's cookie parsing wasn't correct
(was checking for String.Empty rather than null)
--Shahms
Index: HttpWebRequest.cs
===================================================================
RCS file: /mono/mcs/class/System/System.Net/HttpWebRequest.cs,v
retrieving revision 1.6
diff -u -r1.6 HttpWebRequest.cs
--- HttpWebRequest.cs 4 Sep 2002 01:42:23 -0000 1.6
+++ HttpWebRequest.cs 9 Sep 2002 22:53:13 -0000
@@ -565,17 +569,17 @@
: base (HttpWebStream.CreateSocket (webRequest), true)
{
StreamWriter webWriter = null;
- string headerValue = null;
-
webWriter = new StreamWriter (this);
- webWriter.Write (webRequest.Method + " " + webRequest.actualUri.AbsolutePath + " HTTP/1.1\r\n");
+ webWriter.Write (webRequest.Method + " " +
+ webRequest.actualUri.AbsolutePath + " HTTP/" + webRequest.version.ToString(2) + "\r\n");
+
+ foreach (string header in webRequest.webHeaders)
+ webWriter.Write (header + ": " + webRequest.webHeaders[header] + "\r\n");
+
+ // FIXME: write cookie headers (CookieContainer not yet implemented)
- foreach (string header in webRequest.webHeaders) {
- headerValue = header + ": " + webRequest.webHeaders[header] + "\r\n";
- webWriter.Write (headerValue);
- }
webWriter.Write ("\r\n");
webWriter.Flush();
Index: HttpWebResponse.cs
===================================================================
RCS file: /mono/mcs/class/System/System.Net/HttpWebResponse.cs,v
retrieving revision 1.5
diff -u -r1.5 HttpWebResponse.cs
--- HttpWebResponse.cs 4 Sep 2002 01:42:23 -0000 1.5
+++ HttpWebResponse.cs 9 Sep 2002 22:53:13 -0000
@@ -75,7 +76,6 @@
}
this.webHeaders[last] = value.ToString(); // otherwise we miss the last header
- // TODO: parse cookies from headers
}
protected HttpWebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext)
@@ -342,7 +342,7 @@
parts = ((string)options.Dequeue()).Split ('=');
switch (parts[0].ToUpper()) { // cookie options are case-insensitive
case "COMMENT":
- if (cookie.Comment == String.Empty)
+ if (cookie.Comment == null)
cookie.Comment = parts[1];
break;
case "COMMENTURL":
@@ -353,7 +353,7 @@
cookie.Discard = true;
break;
case "DOMAIN":
- if (cookie.Domain == String.Empty)
+ if (cookie.Domain == null)
cookie.Domain = parts[1];
break;
case "MAX-AGE": // RFC Style Set-Cookie2
@@ -365,11 +365,11 @@
cookie.Expires = DateTime.Parse (parts[1]);
break;
case "PATH":
- if (cookie.Path == String.Empty)
+ if (cookie.Path == null)
cookie.Path = parts[1];
break;
case "PORT":
- if (cookie.Port == String.Empty)
+ if (cookie.Port == null)
cookie.Port = parts[1];
break;
case "SECURE":
@@ -383,6 +383,9 @@
if (cookieCollection == null)
cookieCollection = new CookieCollection();
+
+ if (cookie.Domain == null)
+ cookie.Domain = uri.Host;
cookieCollection.Add (cookie);
}