[tests] Don't assume specific charset
authorMarek Habersack <grendel@twistedcode.net>
Fri, 12 Jun 2015 15:33:24 +0000 (17:33 +0200)
committerMarek Habersack <grendel@twistedcode.net>
Wed, 15 Jul 2015 18:45:21 +0000 (20:45 +0200)
Don't assume a specific charset in HTTP response from a server. Google
changes response charset based on the country of the client's
IP. There's no point in checking for the specific charset, it's enough
to check whether the response header has correct format.

mcs/class/System/Test/System.Net/HttpWebRequestTest.cs

index be2bf34d1d6d5e0ad1f0e403f6019f744ea0bae3..c39d2b4dd486abd6fb2075c26601493ae7644a57 100644 (file)
@@ -70,7 +70,7 @@ namespace MonoTests.System.Net
                        Assert.AreEqual ("OK", res.StatusCode.ToString (), "#B1");
                        Assert.AreEqual ("OK", res.StatusDescription, "#B2");
 
-                       Assert.AreEqual ("text/html; charset=ISO-8859-1", res.Headers.Get ("Content-Type"), "#C1");
+                       Assert.IsTrue (res.Headers.Get ("Content-Type").StartsWith ("text/html; charset=", StringComparison.OrdinalIgnoreCase), "#C1");
                        Assert.IsNotNull (res.LastModified, "#C2");
                        Assert.AreEqual (0, res.Cookies.Count, "#C3");