[Mono-list] updated patch for HttpWebResponse

Shahms E. King shahms@shahms.com
09 Sep 2002 15:52:47 -0700


--=-BObyNdnOoWLQi+Tw9nJD
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

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

--=-BObyNdnOoWLQi+Tw9nJD
Content-Disposition: attachment; filename=WebResponse-update.patch
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; name=WebResponse-update.patch; charset=ISO-8859-1

Index: HttpWebRequest.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 =3D null;
-				string headerValue =3D null;
-
=20
 				webWriter =3D new StreamWriter (this);
 =09
-				webWriter.Write (webRequest.Method + " " + webRequest.actualUri.Absolu=
tePath + " HTTP/1.1\r\n");
+				webWriter.Write (webRequest.Method + " " +=20
+					webRequest.actualUri.AbsolutePath + " HTTP/" + webRequest.version.ToS=
tring(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)
=20
-				foreach (string header in webRequest.webHeaders) {
-					headerValue =3D header + ": " + webRequest.webHeaders[header] + "\r\n=
";
-					webWriter.Write (headerValue);
-				}
 				webWriter.Write ("\r\n");
 				webWriter.Flush();
=20
Index: HttpWebResponse.cs
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 @@
 			}
 		=09
 			this.webHeaders[last] =3D value.ToString(); // otherwise we miss the la=
st header
-			// TODO: parse cookies from headers
 		}
 	=09
 		protected HttpWebResponse (SerializationInfo serializationInfo, Streamin=
gContext streamingContext)
@@ -342,7 +342,7 @@
 				parts =3D ((string)options.Dequeue()).Split ('=3D');
 				switch (parts[0].ToUpper()) { // cookie options are case-insensitive
 					case "COMMENT":
-						if (cookie.Comment =3D=3D String.Empty)
+						if (cookie.Comment =3D=3D null)
 							cookie.Comment =3D parts[1];
 					break;
 					case "COMMENTURL":
@@ -353,7 +353,7 @@
 						cookie.Discard =3D true;
 					break;
 					case "DOMAIN":
-						if (cookie.Domain =3D=3D String.Empty)
+						if (cookie.Domain =3D=3D null)
 							cookie.Domain =3D parts[1];
 					break;
 					case "MAX-AGE": // RFC Style Set-Cookie2
@@ -365,11 +365,11 @@
 							cookie.Expires =3D DateTime.Parse (parts[1]);
 					break;
 					case "PATH":
-						if (cookie.Path =3D=3D String.Empty)
+						if (cookie.Path =3D=3D null)
 							cookie.Path =3D parts[1];
 					break;
 					case "PORT":
-						if (cookie.Port =3D=3D String.Empty)
+						if (cookie.Port =3D=3D null)
 							cookie.Port =3D parts[1];
 					break;
 					case "SECURE":
@@ -383,6 +383,9 @@
=20
 			if (cookieCollection =3D=3D null)
 				cookieCollection =3D new CookieCollection();
+
+			if (cookie.Domain =3D=3D null)
+				cookie.Domain =3D uri.Host;
=20
 			cookieCollection.Add (cookie);
 		}

--=-BObyNdnOoWLQi+Tw9nJD--