Selaa lähdekoodia

In System.Net:
2006-04-03 Chris Toshok <[email protected]>

* HttpWebResponse.cs (ContentEncoding): return "" if the header
isn't present.

In Test/System.Net:
2006-04-03 Chris Toshok <[email protected]>

* HttpWebRequestTest.cs (Missing_ContentEncoding): add test to
handle missing content encoding header.


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

Chris Toshok 20 vuotta sitten
vanhempi
sitoutus
e11d804054

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

@@ -1,3 +1,8 @@
+2006-04-03  Chris Toshok  <[email protected]>
+
+	* HttpWebResponse.cs (ContentEncoding): return "" if the header
+	isn't present.
+
 2006-03-30  Atsushi Enomoto  <[email protected]>
 
 	* DownloadStringCompletedEventHandler.cs : missing delegate.

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

@@ -118,7 +118,8 @@ namespace System.Net
 		public string ContentEncoding {
 			get { 
 				CheckDisposed ();
-				return webHeaders ["Content-Encoding"];
+				string h = webHeaders ["Content-Encoding"];
+				return h != null ? h : "";
 			}
 		}
 		

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

@@ -1,3 +1,8 @@
+2006-04-03  Chris Toshok  <[email protected]>
+
+	* HttpWebRequestTest.cs (Missing_ContentEncoding): add test to
+	handle missing content encoding header.
+
 2006-03-28  Atsushi Enomoto  <[email protected]>
 
 	* DnsTest.cs : added test for GetHostEntry.

+ 22 - 0
mcs/class/System/Test/System.Net/HttpWebRequestTest.cs

@@ -124,6 +124,28 @@ namespace MonoTests.System.Net
 			}
 		}
 
+		[Test]
+		public void Missing_ContentEncoding ()
+		{
+			ServicePointManager.CertificatePolicy = new AcceptAllPolicy ();
+			try {
+				BadChunkedServer server = new BadChunkedServer ();
+				server.Start ();
+
+				string url = String.Format ("http://{0}:{1}/nothing.html", server.IPAddress, server.Port);
+				HttpWebRequest request = (HttpWebRequest) WebRequest.Create (url);
+				request.Method = "GET";
+				HttpWebResponse resp = (HttpWebResponse) request.GetResponse ();
+				Assert.AreEqual ("", resp.ContentEncoding);
+				resp.Close ();
+				server.Stop ();
+				if (server.Error != null)
+					throw server.Error;
+			} finally {
+				ServicePointManager.CertificatePolicy = null;
+			}
+		}
+
 		[Test]
 		public void BadServer_ChunkedClose ()
 		{