[System]: Fix System.IO.Compression.CompressionLevel enum.
[mono.git] / mcs / class / System / System.Net / HttpWebResponse.jvm.cs
index c79806e1f3671f7f9109e9fe2cdf9183eb131fe9..f22222b027f86a37f83d64509f1b885888babc7a 100644 (file)
@@ -122,7 +122,7 @@ namespace System.Net
                                string contentType = ContentType;\r
                                if (contentType == null)\r
                                        return "ISO-8859-1";\r
-                               int pos = contentType.IndexOf ("charset=", StringComparison.InvariantCultureIgnoreCase);\r
+                               int pos = contentType.IndexOf ("charset=", StringComparison.OrdinalIgnoreCase);\r
                                if (pos == -1)\r
                                        return "ISO-8859-1";\r
                                pos += 8;\r
@@ -363,8 +363,29 @@ namespace System.Net
                        else\r
                                _version = null;\r
                }\r
-       \r
-               private void FillCookies()\r
+\r
+               private mainsoft.apache.commons.httpclient.Cookie FindCookie (mainsoft.apache.commons.httpclient.Cookie [] cookies, string name) {\r
+                       for (int i = 0; i < cookies.Length; ++i)\r
+                               if (cookies [i].getName () == name)\r
+                                       return cookies [i];\r
+                       return null;\r
+               }\r
+\r
+               private mainsoft.apache.commons.httpclient.Cookie [] FetchResponseCookies (mainsoft.apache.commons.httpclient.Header [] headers,\r
+                                                                                                                                                               mainsoft.apache.commons.httpclient.Cookie [] stateCookies) {\r
+                       System.Collections.ArrayList list = new System.Collections.ArrayList();\r
+                       foreach (mainsoft.apache.commons.httpclient.Header h in headers) {\r
+                               foreach (mainsoft.apache.commons.httpclient.HeaderElement element in h.getValues ()) {\r
+                                       mainsoft.apache.commons.httpclient.Cookie c = FindCookie (stateCookies, element.getName ());\r
+                                       if (c != null)\r
+                                               list.Add(c);\r
+                               }\r
+                       }\r
+\r
+                       return (mainsoft.apache.commons.httpclient.Cookie[]) list.ToArray(typeof(mainsoft.apache.commons.httpclient.Cookie));\r
+               }\r
+\r
+               private void FillCookies ()\r
                {\r
                        if(_state == null)\r
                                return;\r
@@ -375,6 +396,10 @@ namespace System.Net
                        if(javaCookies == null)\r
                                return;\r
 \r
+                       mainsoft.apache.commons.httpclient.Header [] headers = _httpMethod.getResponseHeaders ("Set-Cookie");\r
+                       if (headers != null)\r
+                               javaCookies = FetchResponseCookies (headers, javaCookies);                                              \r
+\r
                        for(int i = 0; i < javaCookies.Length; i++)\r
                        {\r
                                bool httpsProtocol = _httpMethod.getURI().ToString().StartsWith("https");\r