2009-09-15 Gonzalo Paniagua Javier <gonzalo@novell.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Tue, 15 Sep 2009 18:47:01 +0000 (18:47 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Tue, 15 Sep 2009 18:47:01 +0000 (18:47 -0000)
* System.Net.Configuration/DefaultProxyHandler.cs:
* System.Net/WebRequest.cs: handle upper and lowercase HTTP_PROXY and
the Any address.
Fixes bug #537283.

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

mcs/class/System/System.Net.Configuration/ChangeLog
mcs/class/System/System.Net.Configuration/DefaultProxyHandler.cs
mcs/class/System/System.Net/ChangeLog
mcs/class/System/System.Net/WebRequest.cs

index 3505792ba353b1a7cefd109f4aa2a3b9976c24a0..72a80d5cf5c5d1114dc4414b20638d64cb5fe32a 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-15 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * DefaultProxyHandler.cs: handle upper and lowercase HTTP_PROXY and
+       the Any address.  Fixes bug #537283.
+
 2009-06-05 Marek Safar <marek.safar@gmail.com>
 
        * NetConfigurationHandler.cs, DefaultProxyHandler.cs, 
index cd44bfc86fb870a4ce0044125b8b267f846f20b4..99514ebddb88c325ff7a32c05819375d5f28d5a2 100644 (file)
@@ -86,10 +86,27 @@ namespace System.Net.Configuration
                                        //MS: presence of valid address URI takes precedence over usesystemdefault
                                        if (sysdefault != null && String.Compare (sysdefault, "true", true) == 0) {
                                                address = Environment.GetEnvironmentVariable ("http_proxy");
-                                               if (address != null)
+                                               if (address == null)
+                                                       address = Environment.GetEnvironmentVariable ("HTTP_PROXY");
+
+                                               if (address != null) {
                                                        try {
-                                                               ((WebProxy) result).Address = new Uri (address);
-                                                       } catch (UriFormatException) {}
+                                                               Uri uri = new Uri (address);
+                                                               IPAddress ip;
+                                                               if (IPAddress.TryParse (uri.Host, out ip)) {
+                                                                       if (IPAddress.Any.Equals (ip)) {
+                                                                               UriBuilder builder = new UriBuilder (uri);
+                                                                               builder.Host = "127.0.0.1";
+                                                                               uri = builder.Uri;
+                                                                       } else if (IPAddress.IPv6Any.Equals (ip)) {
+                                                                               UriBuilder builder = new UriBuilder (uri);
+                                                                               builder.Host = "[::1]";
+                                                                               uri = builder.Uri;
+                                                                       }
+                                                               }
+                                                               ((WebProxy) result).Address = uri;
+                                                       } catch (UriFormatException) { }
+                                               }
                                        }
                                        
                                        continue;
index 06f0f5fa4639b4f64212b401944077355e3613fd..25153c88b28d32bd2651ad4d8c92829b34690091 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-15 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * WebRequest.cs: handle upper and lowercase HTTP_PROXY and the Any
+       address. Fixes bug #537283.
+
 2009-09-04 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * WebConnection.cs: if the request has already finished reading, don't
index 47edbf1bc984886f737fa8d9fe35da5dd0a49682..43ddcaaffd32e0b1fdb6becee915a409e7c791a8 100644 (file)
@@ -315,11 +315,28 @@ namespace System.Net
                public static IWebProxy GetSystemWebProxy ()
                {
                        string address = Environment.GetEnvironmentVariable ("http_proxy");
+                       if (address == null)
+                               address = Environment.GetEnvironmentVariable ("HTTP_PROXY");
+
                        if (address != null) {
                                try {
-                                       WebProxy p = new WebProxy (address);
-                                       return p;
-                               } catch (UriFormatException) {}
+                                       if (!address.StartsWith ("http://"))
+                                               address = "http://" + address;
+                                       Uri uri = new Uri (address);
+                                       IPAddress ip;
+                                       if (IPAddress.TryParse (uri.Host, out ip)) {
+                                               if (IPAddress.Any.Equals (ip)) {
+                                                       UriBuilder builder = new UriBuilder (uri);
+                                                       builder.Host = "127.0.0.1";
+                                                       uri = builder.Uri;
+                                               } else if (IPAddress.IPv6Any.Equals (ip)) {
+                                                       UriBuilder builder = new UriBuilder (uri);
+                                                       builder.Host = "[::1]";
+                                                       uri = builder.Uri;
+                                               }
+                                       }
+                                       return new WebProxy (uri);
+                               } catch (UriFormatException) { }
                        }
                        return new WebProxy ();
                }