Browse Source

* HttpListenerRequest.cs: Do not store 'method' in upper case, but
instead use case-insensitive comparison.
* HttpListenerRequestTest.cs: Added test for HttpMethod.

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

Gert Driesen 18 years ago
parent
commit
e722420bd3

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

@@ -1,3 +1,8 @@
+2007-09-30  Gert Driesen  <[email protected]>
+
+	* HttpListenerRequest.cs: Do not store 'method' in upper case, but
+	instead use case-insensitive comparison.
+
 2007-09-30  Gert Driesen  <[email protected]>
 
 	* HttpListenerRequest.cs: Removed dead code. USe String.Length to

+ 6 - 3
mcs/class/System/System.Net/HttpListenerRequest.cs

@@ -58,6 +58,8 @@ namespace System.Net {
 		HttpListenerContext context;
 		bool is_chunked;
 		static byte [] _100continue = Encoding.ASCII.GetBytes ("HTTP/1.1 100 Continue\r\n\r\n");
+		static readonly string [] no_body_methods = new string [] {
+			"GET", "HEAD", "DELETE" };
 
 		internal HttpListenerRequest (HttpListenerContext context)
 		{
@@ -76,7 +78,7 @@ namespace System.Net {
 				return;
 			}
 
-			method = parts [0].ToUpperInvariant ();
+			method = parts [0];
 			foreach (char c in method){
 				int ic = (int) c;
 
@@ -169,8 +171,9 @@ namespace System.Net {
 
 			is_chunked = (t_encoding == "chunked");
 
-			if (method == "GET" || method == "HEAD" || method == "DELETE")
-				return;
+			foreach (string m in no_body_methods)
+				if (string.Compare (method, m, StringComparison.InvariantCultureIgnoreCase) == 0)
+					return;
 
 			if (!is_chunked && !cl_set) {
 				context.Connection.SendError (null, 411);

+ 4 - 0
mcs/class/System/Test/System.Net/ChangeLog

@@ -1,3 +1,7 @@
+2007-09-30  Gert Driesen  <[email protected]>
+
+	* HttpListenerRequestTest.cs: Added test for HttpMethod.
+
 2007-09-30  Gert Driesen  <[email protected]>
 
 	* HttpListenerRequestTest.cs: Added test for HasEntityBody.

+ 15 - 1
mcs/class/System/Test/System.Net/HttpListenerRequestTest.cs

@@ -147,7 +147,21 @@ namespace MonoTests.System.Net
 
 			listener.Close ();
 		}
+
+		[Test]
+		public void HttpMethod ()
+		{
+			HttpListener listener = HttpListener2Test.CreateAndStartListener (
+				"http://127.0.0.1:9000/HttpMethod/");
+			NetworkStream ns = HttpListener2Test.CreateNS (9000);
+			HttpListener2Test.Send (ns, "pOsT /HttpMethod/ HTTP/1.1\r\nHost: 127.0.0.1\r\nContent-Length: 3\r\n\r\n123");
+			HttpListenerContext ctx = listener.GetContext ();
+			HttpListenerRequest request = ctx.Request;
+			Assert.AreEqual ("pOsT", request.HttpMethod);
+			HttpListener2Test.Send (ctx.Response.OutputStream, "%%%OK%%%");
+			listener.Close ();
+		}
 	}
-}	
+}
 
 #endif