[System] WebProxy from referencesource
authorMarek Safar <marek.safar@gmail.com>
Fri, 27 May 2016 15:57:45 +0000 (17:57 +0200)
committerMarek Safar <marek.safar@gmail.com>
Tue, 31 May 2016 07:58:26 +0000 (09:58 +0200)
20 files changed:
mcs/class/System/Makefile
mcs/class/System/ReferenceSources/AutoWebProxyScriptEngine.cs [new file with mode: 0644]
mcs/class/System/ReferenceSources/Logging.cs
mcs/class/System/ReferenceSources/RequestCacheProtocol.cs [new file with mode: 0644]
mcs/class/System/ReferenceSources/SR2.cs
mcs/class/System/ReferenceSources/SettingsSectionInternal.cs
mcs/class/System/ReferenceSources/SystemNetworkCredential.cs [deleted file]
mcs/class/System/System.Net/CredentialCache.cs [deleted file]
mcs/class/System/System.Net/GlobalProxySelection.cs [deleted file]
mcs/class/System/System.Net/HttpWebRequest.cs
mcs/class/System/System.Net/ServicePointManager.cs
mcs/class/System/System.Net/WebProxy.cs [deleted file]
mcs/class/System/System.dll.sources
mcs/class/System/mobile_System.dll.sources
mcs/class/referencesource/System/net/System/Net/Cache/RequestCacheManager.cs
mcs/class/referencesource/System/net/System/Net/Internal.cs
mcs/class/referencesource/System/net/System/Net/WebRequest.cs
mcs/class/referencesource/System/net/System/Net/_ProxyChain.cs
mcs/class/referencesource/System/net/System/Net/_TimerThread.cs
mcs/class/referencesource/System/net/System/Net/webproxy.cs

index d4c83ee497c8c96135c73c406b5a70dc9a9bdc47..b5fb6bb927c52ea13578e019c868e4039664ec34 100644 (file)
@@ -42,6 +42,11 @@ REFERENCE_SOURCES_FLAGS += -d:MONO_FEATURE_THREAD_SUSPEND_RESUME
 TEST_MCS_FLAGS += -d:MONO_FEATURE_THREAD_SUSPEND_RESUME
 endif
 
+ifndef NO_MULTIPLE_APPDOMAINS
+REFERENCE_SOURCES_FLAGS += -d:MONO_FEATURE_MULTIPLE_APPDOMAINS
+TEST_MCS_FLAGS += -d:MONO_FEATURE_MULTIPLE_APPDOMAINS
+endif
+
 TXT_RESOURCE_STRINGS = ../referencesource/System/System.txt
 
 #
diff --git a/mcs/class/System/ReferenceSources/AutoWebProxyScriptEngine.cs b/mcs/class/System/ReferenceSources/AutoWebProxyScriptEngine.cs
new file mode 100644 (file)
index 0000000..4e4d285
--- /dev/null
@@ -0,0 +1,179 @@
+using System.Collections;
+using System.Collections.Generic;
+using System.Text.RegularExpressions;
+using Mono.Net;
+
+namespace System.Net
+{
+       class AutoWebProxyScriptEngine
+       {
+               public AutoWebProxyScriptEngine (WebProxy proxy, bool useRegistry)
+               {
+               }
+
+               public Uri AutomaticConfigurationScript { get; set; }
+               public bool AutomaticallyDetectSettings { get; set; }
+
+               public bool GetProxies (Uri destination, out IList<string> proxyList)
+               {
+                       int i = 0;
+                       return GetProxies (destination, out proxyList, ref i);
+               }
+
+               public bool GetProxies(Uri destination, out IList<string> proxyList, ref int syncStatus)
+               {
+                       proxyList = null;
+                       return false;
+               }
+
+               public void Close ()
+               {
+               }
+
+               public void Abort (ref int syncStatus)
+               {
+               }
+
+               public void CheckForChanges ()
+               {
+               }
+
+#if !MOBILE
+               public WebProxyData GetWebProxyData ()
+               {
+                       WebProxyData data;
+
+                       // TODO: Could re-use some pieces from _AutoWebProxyScriptEngine.cs
+                       if (IsWindows ()) {
+                               data = InitializeRegistryGlobalProxy ();
+                               if (data != null)
+                                       return data;
+                       }
+
+                       data = ReadEnvVariables ();
+                       return data ?? new WebProxyData ();
+               }
+
+               WebProxyData ReadEnvVariables ()
+               {
+                       string address = Environment.GetEnvironmentVariable ("http_proxy") ?? Environment.GetEnvironmentVariable ("HTTP_PROXY");
+
+                       if (address != null) {
+                               try {
+                                       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;
+                                               }
+                                       }
+
+                                       bool bBypassOnLocal = false;
+                                       ArrayList al = new ArrayList ();
+                                       string bypass = Environment.GetEnvironmentVariable ("no_proxy") ?? Environment.GetEnvironmentVariable ("NO_PROXY");
+                                       
+                                       if (bypass != null) {
+                                               string[] bypassList = bypass.Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+                                       
+                                               foreach (string str in bypassList) {
+                                                       if (str != "*.local")
+                                                               al.Add (str);
+                                                       else
+                                                               bBypassOnLocal = true;
+                                               }
+                                       }
+
+                                       return new WebProxyData {
+                                               proxyAddress = uri,
+                                               bypassOnLocal = bBypassOnLocal,
+                                               bypassList = CreateBypassList (al)
+                                       };
+                               } catch (UriFormatException) {
+                               }
+                       }
+
+                       return null;
+               }
+
+               static bool IsWindows ()
+               {
+                       return (int) Environment.OSVersion.Platform < 4;
+               }
+                               
+               WebProxyData InitializeRegistryGlobalProxy ()
+               {
+                       int iProxyEnable = (int)Microsoft.Win32.Registry.GetValue ("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", "ProxyEnable", 0);
+
+                       if (iProxyEnable > 0) {
+                               string strHttpProxy = "";
+                               bool bBypassOnLocal = false;
+                               ArrayList al = new ArrayList ();
+                               
+                               string strProxyServer = (string)Microsoft.Win32.Registry.GetValue ("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", "ProxyServer", null);
+                               string strProxyOverrride = (string)Microsoft.Win32.Registry.GetValue ("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", "ProxyOverride", null);
+                               
+                               if (strProxyServer.Contains ("=")) {
+                                       foreach (string strEntry in strProxyServer.Split (new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
+                                               if (strEntry.StartsWith ("http=")) {
+                                                       strHttpProxy = strEntry.Substring (5);
+                                                       break;
+                                               }
+                               } else strHttpProxy = strProxyServer;
+                               
+                               if (strProxyOverrride != null) {
+                                       string[] bypassList = strProxyOverrride.Split (new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
+                               
+                                       foreach (string str in bypassList) {
+                                               if (str != "<local>")
+                                                       al.Add (str);
+                                               else
+                                                       bBypassOnLocal = true;
+                                       }
+                               }
+
+                               return new WebProxyData {
+                                       proxyAddress = ToUri (strHttpProxy),
+                                       bypassOnLocal = bBypassOnLocal,
+                                       bypassList = CreateBypassList (al)
+                               };
+                       }
+
+                       return null;
+               }
+
+               static Uri ToUri (string address)
+               {
+                       if (address == null)
+                               return null;
+                               
+                       if (address.IndexOf ("://", StringComparison.Ordinal) == -1) 
+                               address = "http://" + address;
+
+                       return new Uri (address);
+               }
+
+               // Takes an ArrayList of fileglob-formatted strings and returns an array of Regex-formatted strings
+               static ArrayList CreateBypassList (ArrayList al)
+               {
+                       string[] result = al.ToArray (typeof (string)) as string[];
+                       for (int c = 0; c < result.Length; c++)
+                       {
+                               result [c] = "^" +
+                                       Regex.Escape (result [c]).Replace (@"\*", ".*").Replace (@"\?", ".") +
+                                       "$";
+                       }
+                       return new ArrayList (result);
+               }
+#endif
+       }
+}
\ No newline at end of file
index 35474720e7a493f8a4e14965a2d609913f2051ed..e4af8e1eca2eab2091d85033af6864650a0e6163 100644 (file)
@@ -37,6 +37,14 @@ namespace System.Net {
                internal static void PrintInfo(TraceSource traceSource, object obj, string method, string msg) {
                }
 
+               [Conditional ("TRACE")]
+               internal static void PrintInfo(TraceSource traceSource, object obj, string msg) {
+               }
+
+               [Conditional ("TRACE")]
+               internal static void PrintInfo(TraceSource traceSource, string msg) {
+               }
+
                [Conditional ("TRACE")]
                internal static void PrintWarning(TraceSource traceSource, object obj, string method, string msg) {
                }
@@ -44,6 +52,10 @@ namespace System.Net {
                [Conditional ("TRACE")]
                internal static void PrintWarning(TraceSource traceSource, string msg) {
                }
+
+               [Conditional ("TRACE")]
+               internal static void PrintError(TraceSource traceSource, string msg) {
+               }
        }
 
 #if MOBILE
diff --git a/mcs/class/System/ReferenceSources/RequestCacheProtocol.cs b/mcs/class/System/ReferenceSources/RequestCacheProtocol.cs
new file mode 100644 (file)
index 0000000..b9805f3
--- /dev/null
@@ -0,0 +1,10 @@
+namespace System.Net.Cache
+{
+       class RequestCacheProtocol
+       {
+               public RequestCacheProtocol (object arg1, object arg2)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+}
\ No newline at end of file
index 35d8f634c02343e74fa0d4c0de01d6c69129a832..dfec0bc910e666f28b3d9e57749c0cb8178ff984 100644 (file)
@@ -3,10 +3,12 @@
 //
 // Copyright 2014 Xamarin Inc
 //
-// Mono-specific additions, which are not in SR.cs.
+// Mono-specific additions, which are not in SR.cs or missing in referencesource
 //
 partial class SR
 {
        public const string mono_net_io_shutdown = "mono_net_io_shutdown";
        public const string mono_net_io_renegotiate = "mono_net_io_renegotiate";
+
+       public const string  net_log_set_socketoption_reuseport_default_on = "net_log_set_socketoption_reuseport_default_on";
 }
index 595c569e6c4a39edb008bec8bff173773ddda1ff..c186fbfc5eec5e3ba5aa51d87c9b7549352f1e90 100644 (file)
@@ -1,3 +1,5 @@
+using System.Net.Security;
+
 namespace System.Net.Configuration {
        sealed class SettingsSectionInternal
        {
@@ -15,5 +17,14 @@ namespace System.Net.Configuration {
 #endif
 
                internal bool HttpListenerUnescapeRequestUrl = true;
+
+
+               internal bool UseNagleAlgorithm { get; set; }
+               internal bool Expect100Continue { get; set; }
+               internal bool CheckCertificateName { get; }
+               internal int DnsRefreshTimeout { get; set; }
+               internal bool EnableDnsRoundRobin { get; set; }
+               internal bool CheckCertificateRevocationList { get; set; }
+               internal EncryptionPolicy EncryptionPolicy { get; }
        }
 }
diff --git a/mcs/class/System/ReferenceSources/SystemNetworkCredential.cs b/mcs/class/System/ReferenceSources/SystemNetworkCredential.cs
deleted file mode 100644 (file)
index 71f87c8..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace System.Net {
-    //
-    // Object representing default credentials
-    //
-    internal class SystemNetworkCredential : NetworkCredential {
-        internal static readonly SystemNetworkCredential defaultCredential = new SystemNetworkCredential();
-
-        // We want reference equality to work.  Making this private is a good way to guarantee that.
-        private SystemNetworkCredential() :
-            base(string.Empty, string.Empty, string.Empty) {
-        }
-    }
-}
\ No newline at end of file
diff --git a/mcs/class/System/System.Net/CredentialCache.cs b/mcs/class/System/System.Net/CredentialCache.cs
deleted file mode 100644 (file)
index 9978daa..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-//
-// System.Net.CredentialCache.cs
-//
-// Author:
-//   Lawrence Pit (loz@cable.a2000.nl)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.Runtime.Serialization;
-
-namespace System.Net {
-       public class CredentialCache : ICredentials, IEnumerable, ICredentialsByHost
-       {
-               static NetworkCredential empty = new NetworkCredential (String.Empty, String.Empty, String.Empty);
-               Hashtable cache;
-               Hashtable cacheForHost;
-
-               public CredentialCache () 
-               {
-                       cache = new Hashtable ();
-                       cacheForHost = new Hashtable ();
-               }
-               
-               [MonoTODO ("Need EnvironmentPermission implementation first")]
-               public static ICredentials DefaultCredentials {
-                       get {
-                               // This is used for NTLM, Kerberos and Negotiate under MS
-                               return empty;
-                       }
-               }
-
-               // MS does might return a special ICredentials which does not allow getting the
-               // username/password information out of it for non-internal classes.
-               public static NetworkCredential DefaultNetworkCredentials {
-                       get { return empty; }
-               }
-
-               public NetworkCredential GetCredential (Uri uriPrefix, string authType)
-               {
-                       int longestPrefix = -1;
-                       NetworkCredential result = null;
-                       
-                       if (uriPrefix == null || authType == null)
-                               return null;
-                               
-                       string absPath = uriPrefix.AbsolutePath;
-                       absPath = absPath.Substring (0, absPath.LastIndexOf ('/'));
-                       
-                       IDictionaryEnumerator e = cache.GetEnumerator ();
-                       while (e.MoveNext ()) {
-                               CredentialCacheKey key = e.Key as CredentialCacheKey;
-                               
-                               if (key.Length <= longestPrefix) 
-                                       continue;
-                               
-                               if (String.Compare (key.AuthType, authType, true) != 0)
-                                       continue;
-                               
-                               Uri cachedUri = key.UriPrefix;
-                               
-                               if (cachedUri.Scheme != uriPrefix.Scheme)
-                                       continue;
-                                       
-                               if (cachedUri.Port != uriPrefix.Port)
-                                       continue;
-                                       
-                               if (cachedUri.Host != uriPrefix.Host)
-                                       continue;
-                                                               
-                               if (!absPath.StartsWith (key.AbsPath))
-                                       continue;
-                                       
-                               longestPrefix = key.Length;
-                               result = (NetworkCredential) e.Value;
-                       }
-                       
-                       return result;
-               }
-
-               public IEnumerator GetEnumerator ()
-               {
-                       return cache.Values.GetEnumerator ();
-               }               
-               
-               public void Add (Uri uriPrefix, string authType, NetworkCredential cred)
-               {
-                       if (uriPrefix == null) 
-                               throw new ArgumentNullException ("uriPrefix");
-
-                       if (authType == null) 
-                               throw new ArgumentNullException ("authType");
-                       
-                       // throws ArgumentException when same key already exists.
-                       cache.Add (new CredentialCacheKey (uriPrefix, authType), cred);
-               }
-               
-               public void Remove (Uri uriPrefix, string authType)
-               {
-                       if (uriPrefix == null) 
-                               throw new ArgumentNullException ("uriPrefix");
-
-                       if (authType == null) 
-                               throw new ArgumentNullException ("authType");
-
-                       cache.Remove (new CredentialCacheKey (uriPrefix, authType));
-               }
-               
-               public NetworkCredential GetCredential (string host, int port, string authenticationType)
-               {
-                       NetworkCredential result = null;
-                       
-                       if (host == null || port < 0 || authenticationType == null)
-                               return null;
-
-                       IDictionaryEnumerator e = cacheForHost.GetEnumerator ();
-                       while (e.MoveNext ()) {
-                               CredentialCacheForHostKey key = e.Key as CredentialCacheForHostKey;
-                               
-                               if (String.Compare (key.AuthType, authenticationType, true) != 0)
-                                       continue;
-                               
-                               if (key.Host != host)
-                                       continue;
-                               
-                               if (key.Port != port)
-                                       continue;
-                               
-                               result = (NetworkCredential) e.Value;
-                       }
-                       
-                       return result;
-               }
-
-               public void Add (string host, int port, string authenticationType, NetworkCredential credential)
-               {
-                       if (host == null)
-                               throw new ArgumentNullException("host");
-
-                       if (port < 0)
-                               throw new ArgumentOutOfRangeException("port");
-
-                       if (authenticationType == null)
-                               throw new ArgumentOutOfRangeException("authenticationType");
-
-                       cacheForHost.Add (new CredentialCacheForHostKey (host, port, authenticationType), credential);
-               }
-
-               public void Remove (string host, int port, string authenticationType)
-               {
-                       if (host == null)
-                               return;
-
-                       if (authenticationType == null)
-                               return;
-
-                       cacheForHost.Remove (new CredentialCacheForHostKey (host, port, authenticationType));
-               }
-
-               class CredentialCacheKey {
-                       Uri uriPrefix;
-                       string authType;
-                       string absPath;
-                       int len;
-                       int hash;
-                       
-                       internal CredentialCacheKey (Uri uriPrefix, string authType)
-                       {
-                               this.uriPrefix = uriPrefix;
-                               this.authType = authType;
-                               
-                               this.absPath = uriPrefix.AbsolutePath;
-                               this.absPath = absPath.Substring (0, absPath.LastIndexOf ('/'));                                
-
-                               this.len = uriPrefix.AbsoluteUri.Length;
-                               this.hash = uriPrefix.GetHashCode () 
-                                         + authType.GetHashCode ();
-                       }
-                       
-                       public int Length {
-                               get { return len; }
-                       }                       
-                       
-                       public string AbsPath {
-                               get { return absPath; }
-                       }
-                       
-                       public Uri UriPrefix {
-                               get { return uriPrefix; }
-                       }
-                       
-                       public string AuthType {
-                               get { return authType; }
-                       }
-                       
-                       public override int GetHashCode ()
-                       {
-                               return hash;
-                       }
-                       
-                       public override bool Equals (object obj)
-                       {
-                               CredentialCacheKey key = obj as CredentialCacheKey;
-                               return ((key != null) && (this.hash == key.hash));
-                       }
-                       
-                       public override string ToString ()
-                       {
-                               return absPath + " : " + authType + " : len=" + len;
-                       }
-               }
-
-               class CredentialCacheForHostKey {
-                       string host;
-                       int port;
-                       string authType;
-                       int hash;
-
-                       internal CredentialCacheForHostKey (string host, int port, string authType)
-                       {
-                               this.host = host;
-                               this.port = port;
-                               this.authType = authType;
-
-                               this.hash = host.GetHashCode ()
-                                       + port.GetHashCode ()
-                                       + authType.GetHashCode ();
-                       }
-
-                       public string Host {
-                               get { return host; }
-                       }
-
-                       public int Port {
-                               get { return port; }
-                       }
-
-                       public string AuthType {
-                               get { return authType; }
-                       }
-
-               public override int GetHashCode ()
-               {
-                       return hash;
-               }
-
-               public override bool Equals (object obj)
-               {
-                       CredentialCacheForHostKey key = obj as CredentialCacheForHostKey;
-                       return ((key != null) && (this.hash == key.hash));
-               }
-
-               public override string ToString ()
-               {
-                       return host + " : " + authType;
-               }
-       }
-}
-}
-
-
diff --git a/mcs/class/System/System.Net/GlobalProxySelection.cs b/mcs/class/System/System.Net/GlobalProxySelection.cs
deleted file mode 100644 (file)
index 049f61c..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-// System.Net.GlobalProxySelection
-//
-// Author:
-//   Lawrence Pit (loz@cable.a2000.nl)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.Configuration;
-using System.IO;
-using System.Runtime.Serialization;
-using System.Net.Configuration;
-
-namespace System.Net 
-{
-       [ObsoleteAttribute("Use WebRequest.DefaultProxy instead")]
-       public class GlobalProxySelection
-       {
-               // Constructors
-               public GlobalProxySelection() { }
-               
-               // Properties
-
-               public static IWebProxy Select {
-                       get { return WebRequest.DefaultWebProxy; }
-                       set { WebRequest.DefaultWebProxy = value; }
-               }
-               
-               // Methods
-               
-               public static IWebProxy GetEmptyWebProxy()
-               {
-                       // must return a new one each time, as the credentials
-                       // can be set
-                       return new EmptyWebProxy ();    
-               }
-               
-               // Internal Classes
-               
-               internal class EmptyWebProxy : IWebProxy {
-                       private ICredentials credentials = null;
-                       
-                       internal EmptyWebProxy () { }
-                       
-                       public ICredentials Credentials {
-                               get { return credentials; } 
-                               set { credentials = value; }
-                       }
-
-                       public Uri GetProxy (Uri destination)
-                       {
-                               return destination;
-                       }
-
-                       public bool IsBypassed (Uri host)
-                       {
-                               return true; // pass directly to host
-                       }
-               }
-       }               
-}
index 97233f4f488ad6cf0340fcfbb15a4c0d96f8c3d6..a151f6bb870e2ed992fa5b5639864d82835979ec 100644 (file)
@@ -154,7 +154,7 @@ namespace System.Net
                {
                        this.requestUri = uri;
                        this.actualUri = uri;
-                       this.proxy = GlobalProxySelection.Select;
+                       this.proxy = InternalDefaultWebProxy;
                        this.webHeaders = new WebHeaderCollection (WebHeaderCollectionType.HttpWebRequest);
                        ThrowOnError = true;
                        ResetAuthorization ();
@@ -1474,7 +1474,7 @@ namespace System.Net
                        if (wce != null) {
                                WebConnection cnc = wce.Connection;
                                cnc.PriorityRequest = this;
-                               ICredentials creds = !isProxy ? credentials : proxy.Credentials;
+                               ICredentials creds = (!isProxy || proxy == null) ? credentials : proxy.Credentials;
                                if (creds != null) {
                                        cnc.NtlmCredential = creds.GetCredential (requestUri, "NTLM");
                                        cnc.UnsafeAuthenticatedConnectionSharing = unsafe_auth_blah;
@@ -1531,7 +1531,7 @@ namespace System.Net
                                        return;
                                }
 
-                               bool isProxy = ProxyQuery && !proxy.IsBypassed (actualUri);
+                               bool isProxy = ProxyQuery && proxy != null && !proxy.IsBypassed (actualUri);
 
                                bool redirected;
                                try {
index abd23e67270d619d6b6435ca104187a9be488401..723125b1e753c867afe58eb58109b3895812ef7d 100644 (file)
@@ -311,7 +311,7 @@ namespace System.Net
 
                public static ServicePoint FindServicePoint (Uri address) 
                {
-                       return FindServicePoint (address, GlobalProxySelection.Select);
+                       return FindServicePoint (address, null);
                }
                
                public static ServicePoint FindServicePoint (string uriString, IWebProxy proxy)
diff --git a/mcs/class/System/System.Net/WebProxy.cs b/mcs/class/System/System.Net/WebProxy.cs
deleted file mode 100644 (file)
index a0f422b..0000000
+++ /dev/null
@@ -1,385 +0,0 @@
-//
-// System.Net.WebProxy.cs
-//
-// Authors:
-//   Lawrence Pit (loz@cable.a2000.nl)
-//   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Collections;
-using System.Globalization;
-using System.Runtime.Serialization;
-using System.Text.RegularExpressions;
-using Mono.Net;
-
-namespace System.Net 
-{
-       [Serializable]
-       public class WebProxy : IWebProxy, ISerializable
-       {
-               Uri address;
-               bool bypassOnLocal;
-               ArrayList bypassList;
-               ICredentials credentials;
-               bool useDefaultCredentials;
-
-               // Constructors
-
-               public WebProxy ()
-                       : this ((Uri) null, false, null, null) {}
-
-               public WebProxy (string address)
-                       : this (ToUri (address), false, null, null) {}
-
-               public WebProxy (Uri address) 
-                       : this (address, false, null, null) {}
-
-               public WebProxy (string address, bool bypassOnLocal) 
-                       : this (ToUri (address), bypassOnLocal, null, null) {}
-
-               public WebProxy (string host, int port)
-                       : this (new Uri ("http://" + host + ":" + port)) {}
-
-               public WebProxy (Uri address, bool bypassOnLocal)
-                       : this (address, bypassOnLocal, null, null) {}
-
-               public WebProxy (string address, bool bypassOnLocal, string [] bypassList)
-                       : this (ToUri (address), bypassOnLocal, bypassList, null) {}
-
-               public WebProxy (Uri address, bool bypassOnLocal, string [] bypassList)
-                       : this (address, bypassOnLocal, bypassList, null) {}
-
-               public WebProxy (string address, bool bypassOnLocal, string [] bypassList,
-                               ICredentials credentials)
-                       : this (ToUri (address), bypassOnLocal, bypassList, credentials) {}
-
-               public WebProxy (Uri address, bool bypassOnLocal, 
-                                string[] bypassList, ICredentials credentials)
-               {
-                       this.address = address;
-                       this.bypassOnLocal = bypassOnLocal;
-                       if (bypassList != null)
-                               this.bypassList = new ArrayList (bypassList);
-                       this.credentials = credentials;
-                       CheckBypassList ();
-               }
-
-               protected WebProxy (SerializationInfo serializationInfo, StreamingContext streamingContext) 
-               {
-                       this.address = (Uri) serializationInfo.GetValue ("_ProxyAddress", typeof (Uri));
-                       this.bypassOnLocal = serializationInfo.GetBoolean ("_BypassOnLocal");
-                       this.bypassList = (ArrayList) serializationInfo.GetValue ("_BypassList", typeof (ArrayList));
-                       this.useDefaultCredentials =  serializationInfo.GetBoolean ("_UseDefaultCredentials");
-                       this.credentials = null;
-                       CheckBypassList ();
-               }
-
-               // Properties
-               public Uri Address {
-                       get { return address; }
-                       set { address = value; }
-               }
-
-               public ArrayList BypassArrayList {
-                       get {
-                               if (bypassList == null)
-                                       bypassList = new ArrayList ();
-                               return bypassList;
-                       }
-               }
-
-               public string [] BypassList {
-                       get { return (string []) BypassArrayList.ToArray (typeof (string)); }
-                       set { 
-                               if (value == null)
-                                       throw new ArgumentNullException ();
-                               bypassList = new ArrayList (value); 
-                               CheckBypassList ();
-                       }
-               }
-
-               public bool BypassProxyOnLocal {
-                       get { return bypassOnLocal; }
-                       set { bypassOnLocal = value; }
-               }
-
-               public ICredentials Credentials {
-                       get { return credentials; }
-                       set { credentials = value; }
-               }
-
-               [MonoTODO ("Does not affect Credentials, since CredentialCache.DefaultCredentials is not implemented.")]
-               public bool UseDefaultCredentials {
-                       get { return useDefaultCredentials; }
-                       set { useDefaultCredentials = value; }
-               }
-
-               // Methods
-               [Obsolete ("This method has been deprecated", false)]
-               [MonoTODO("Can we get this info under windows from the system?")]
-               public static WebProxy GetDefaultProxy ()
-               {
-                       // Select gets a WebProxy from config files, if available.
-                       IWebProxy p = GlobalProxySelection.Select;
-                       if (p is WebProxy)
-                               return (WebProxy) p;
-
-                       return new WebProxy ();
-               }
-
-               public Uri GetProxy (Uri destination)
-               {
-                       if (IsBypassed (destination))
-                               return destination;
-
-                       return address;
-               }
-
-               public bool IsBypassed (Uri host)
-               {
-                       if (host == null)
-                               throw new ArgumentNullException ("host");
-
-                       if (host.IsLoopback && bypassOnLocal)
-                               return true;
-
-                       if (address == null)
-                               return true;
-
-                       string server = host.Host;
-                       if (bypassOnLocal && server.IndexOf ('.') == -1)
-                               return true;
-
-                       // LAMESPEC
-                       if (!bypassOnLocal) {
-                               if (String.Compare (server, "localhost", true, CultureInfo.InvariantCulture) == 0)
-                                       return true;
-                               if (String.Compare (server, "loopback", true, CultureInfo.InvariantCulture) == 0)
-                                       return true;
-
-                               IPAddress addr = null;
-                               if (IPAddress.TryParse (server, out addr) && IPAddress.IsLoopback (addr))
-                                       return true;
-                       }
-
-                       if (bypassList == null || bypassList.Count == 0)
-                               return false;
-
-                       try {
-                               string hostStr = host.Scheme + "://" + host.Authority;
-                               int i = 0;
-                               for (; i < bypassList.Count; i++) {
-                                       Regex regex = new Regex ((string) bypassList [i], 
-                                               // TODO: RegexOptions.Compiled |  // not implemented yet by Regex
-                                               RegexOptions.IgnoreCase |
-                                               RegexOptions.Singleline);
-
-                                       if (regex.IsMatch (hostStr))
-                                               break;
-                               }
-
-                               if (i == bypassList.Count)
-                                       return false;
-
-                               // continue checking correctness of regular expressions..
-                               // will throw expression when an invalid one is found
-                               for (; i < bypassList.Count; i++)
-                                       new Regex ((string) bypassList [i]);
-
-                               return true;
-                       } catch (ArgumentException) {
-                               return false;
-                       }
-               }
-
-               protected virtual void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
-               {
-                       serializationInfo.AddValue ("_BypassOnLocal", bypassOnLocal);
-                       serializationInfo.AddValue ("_ProxyAddress", address);
-                       serializationInfo.AddValue ("_BypassList", bypassList);
-                       serializationInfo.AddValue ("_UseDefaultCredentials", UseDefaultCredentials);
-               }
-
-               void ISerializable.GetObjectData (SerializationInfo serializationInfo,
-                                                 StreamingContext streamingContext)
-               {
-                       GetObjectData (serializationInfo, streamingContext);
-               }
-
-               // Private Methods
-               // this compiles the regular expressions, and will throw
-               // an exception when an invalid one is found.
-               void CheckBypassList ()
-               {
-                       if (bypassList == null)
-                               return;
-                       for (int i = 0; i < bypassList.Count; i++)
-                               new Regex ((string) bypassList [i]);
-               }
-
-               static Uri ToUri (string address)
-               {
-                       if (address == null)
-                               return null;
-                               
-                       if (address.IndexOf ("://", StringComparison.Ordinal) == -1) 
-                               address = "http://" + address;
-
-                       return new Uri (address);
-               }
-
-               internal static IWebProxy CreateDefaultProxy ()
-               {
-#if MONOTOUCH
-                       return CFNetwork.GetDefaultProxy ();
-#elif MONODROID
-                       // Return the system web proxy.  This only works for ICS+.
-                       var androidProxy = AndroidPlatform.GetDefaultProxy ();
-                       if (androidProxy != null)
-                               return androidProxy;
-
-                       return new WebProxy (false);
-#else
-                       if (Platform.IsMacOS)
-                               return CFNetwork.GetDefaultProxy ();
-
-                       return new WebProxy (false);
-#endif
-               }
-
-               // Global settings initialization
-               private WebProxy (bool enableAutoproxy)
-               {
-#if !MOBILE                    
-                       if (IsWindows () && InitializeRegistryGlobalProxy ())
-                               return;
-#endif
-                       string address = Environment.GetEnvironmentVariable ("http_proxy") ?? Environment.GetEnvironmentVariable ("HTTP_PROXY");
-
-                       if (address != null) {
-                               try {
-                                       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;
-                                               }
-                                       }
-
-                                       bool bBypassOnLocal = false;
-                                       ArrayList al = new ArrayList ();
-                                       string bypass = Environment.GetEnvironmentVariable ("no_proxy") ?? Environment.GetEnvironmentVariable ("NO_PROXY");
-                                       
-                                       if (bypass != null) {
-                                               string[] bypassList = bypass.Split (new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
-                                       
-                                               foreach (string str in bypassList) {
-                                                       if (str != "*.local")
-                                                               al.Add (str);
-                                                       else
-                                                               bBypassOnLocal = true;
-                                               }
-                                       }
-
-                                       this.address = uri;
-                                       this.bypassOnLocal = bBypassOnLocal;
-                                       this.bypassList = CreateBypassList (al);
-                                       return;
-                               } catch (UriFormatException) {
-                               }
-                       }
-               }
-
-#if !MOBILE
-               static bool IsWindows ()
-               {
-                       return (int) Environment.OSVersion.Platform < 4;
-               }
-                               
-               bool InitializeRegistryGlobalProxy ()
-               {
-                       int iProxyEnable = (int)Microsoft.Win32.Registry.GetValue ("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", "ProxyEnable", 0);
-
-                       if (iProxyEnable > 0) {
-                               string strHttpProxy = "";
-                               bool bBypassOnLocal = false;
-                               ArrayList al = new ArrayList ();
-                               
-                               string strProxyServer = (string)Microsoft.Win32.Registry.GetValue ("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", "ProxyServer", null);
-                               string strProxyOverrride = (string)Microsoft.Win32.Registry.GetValue ("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", "ProxyOverride", null);
-                               
-                               if (strProxyServer.Contains ("=")) {
-                                       foreach (string strEntry in strProxyServer.Split (new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
-                                               if (strEntry.StartsWith ("http=")) {
-                                                       strHttpProxy = strEntry.Substring (5);
-                                                       break;
-                                               }
-                               } else strHttpProxy = strProxyServer;
-                               
-                               if (strProxyOverrride != null) {
-                                       string[] bypassList = strProxyOverrride.Split (new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
-                               
-                                       foreach (string str in bypassList) {
-                                               if (str != "<local>")
-                                                       al.Add (str);
-                                               else
-                                                       bBypassOnLocal = true;
-                                       }
-                               }
-
-                               this.address = ToUri (strHttpProxy);
-                               this.bypassOnLocal = bBypassOnLocal;
-                               this.bypassList = CreateBypassList (al);
-                               return true;
-                       }
-
-                       return false;
-               }
-#endif
-
-               // Takes an ArrayList of fileglob-formatted strings and returns an array of Regex-formatted strings
-               static ArrayList CreateBypassList (ArrayList al)
-               {
-                       string[] result = al.ToArray (typeof (string)) as string[];
-                       for (int c = 0; c < result.Length; c++)
-                       {
-                               result [c] = "^" +
-                                       Regex.Escape (result [c]).Replace (@"\*", ".*").Replace (@"\?", ".") +
-                                       "$";
-                       }
-                       return new ArrayList (result);
-               }
-       }
-}
index da94ec0b10b11941ce096ce91df3cdcc3d04983c..0dd0fa335d53f664722f1abe69b4016ca2cf4319 100644 (file)
@@ -247,7 +247,6 @@ System.Net.Configuration/WebRequestModuleElementCollection.cs
 System.Net.Configuration/WebRequestModuleElement.cs
 System.Net.Configuration/WebRequestModuleHandler.cs
 System.Net.Configuration/WebRequestModulesSection.cs
-System.Net/CredentialCache.cs
 System.Net/DecompressionMethods.cs
 System.Net/DefaultCertificatePolicy.cs
 System.Net/DigestClient.cs
@@ -263,7 +262,6 @@ System.Net/FtpRequestCreator.cs
 System.Net/FtpWebRequest.cs
 System.Net/FtpStatus.cs
 System.Net/FtpWebResponse.cs
-System.Net/GlobalProxySelection.cs
 System.Net/HttpConnection.cs
 System.Net/HttpListenerBasicIdentity.cs
 System.Net/HttpListenerContext.cs
@@ -410,7 +408,6 @@ System.Net/WebConnection.cs
 System.Net/WebConnectionData.cs
 System.Net/WebConnectionGroup.cs
 System.Net/WebConnectionStream.cs
-System.Net/WebProxy.cs
 System.Net.WebSockets/ClientWebSocket.cs
 System.Net.WebSockets/ClientWebSocketOptions.cs
 System.Net.WebSockets/HttpListenerWebSocketContext.cs
@@ -555,6 +552,7 @@ Mono.Net.Security/MonoTlsStream.cs
 Mono.Net.Security/NoReflectionHelper.cs
 Mono.Net.Security/SystemCertificateValidator.cs
 
+ReferenceSources/AutoWebProxyScriptEngine.cs
 ReferenceSources/AssertWrapper.cs
 ReferenceSources/BinaryCompatibility.cs
 ReferenceSources/ConfigurationManagerInternalFactory.cs
@@ -565,12 +563,12 @@ ReferenceSources/HttpApi.cs
 ReferenceSources/HttpSysSettings.cs
 ReferenceSources/Logging.cs
 ReferenceSources/NativeMethods.cs
+ReferenceSources/RequestCacheProtocol.cs
 ReferenceSources/SettingsSectionInternal.cs
 ReferenceSources/Socket.cs
 ReferenceSources/SR.cs
 ReferenceSources/SR2.cs
 ReferenceSources/SRCategoryAttribute.cs
-ReferenceSources/SystemNetworkCredential.cs
 ReferenceSources/Win32Exception.cs
 
 ReferenceSources/SSPIConfiguration.cs
@@ -966,6 +964,7 @@ ReferenceSources/_SslStream.cs
 
 ../referencesource/System/net/System/Net/_BufferOffsetSize.cs
 ../referencesource/System/net/System/Net/_Connection.cs
+../referencesource/System/net/System/Net/_emptywebproxy.cs
 ../referencesource/System/net/System/Net/_HeaderInfo.cs
 ../referencesource/System/net/System/Net/_HeaderInfoTable.cs
 ../referencesource/System/net/System/Net/_HTTPDateParse.cs
@@ -975,9 +974,12 @@ ReferenceSources/_SslStream.cs
 ../referencesource/System/net/System/Net/_LoggingObject.cs
 ../referencesource/System/net/System/Net/_ProxyChain.cs
 ../referencesource/System/net/System/Net/_ScatterGatherBuffers.cs
+../referencesource/System/net/System/Net/_TimerThread.cs
+../referencesource/System/net/System/Net/_WebProxyDataBuilder.cs
 ../referencesource/System/net/System/Net/AuthenticationScheme.cs
 ../referencesource/System/net/System/Net/AuthenticationSchemeSelector.cs
 ../referencesource/System/net/System/Net/Authorization.cs
+../referencesource/System/net/System/Net/CredentialCache.cs
 ../referencesource/System/net/System/Net/cookie.cs
 ../referencesource/System/net/System/Net/cookiecollection.cs
 ../referencesource/System/net/System/Net/cookiecontainer.cs
@@ -987,6 +989,7 @@ ReferenceSources/_SslStream.cs
 ../referencesource/System/net/System/Net/FtpStatusCode.cs
 ../referencesource/System/net/System/Net/filewebrequest.cs
 ../referencesource/System/net/System/Net/filewebresponse.cs
+../referencesource/System/net/System/Net/GlobalProxySelection.cs
 ../referencesource/System/net/System/Net/HttpListenerException.cs
 ../referencesource/System/net/System/Net/HttpListenerRequestUriBuilder.cs
 ../referencesource/System/net/System/Net/HttpRequestHeader.cs
@@ -1002,6 +1005,7 @@ ReferenceSources/_SslStream.cs
 ../referencesource/System/net/System/Net/IPEndPoint.cs
 ../referencesource/System/net/System/Net/IPHostEntry.cs
 ../referencesource/System/net/System/Net/iwebproxy.cs
+../referencesource/System/net/System/Net/IWebProxyFinder.cs
 ../referencesource/System/net/System/Net/IWebRequestCreate.cs
 ../referencesource/System/net/System/Net/NetworkAccess.cs
 ../referencesource/System/net/System/Net/ProtocolViolationException.cs
@@ -1016,6 +1020,7 @@ ReferenceSources/_SslStream.cs
 ../referencesource/System/net/System/Net/WebExceptionStatus.cs
 ../referencesource/System/net/System/Net/WebHeaderCollection.cs
 ../referencesource/System/net/System/Net/WebPermission.cs
+../referencesource/System/net/System/Net/webproxy.cs
 ../referencesource/System/net/System/Net/WebRequestMethods.cs
 ../referencesource/System/net/System/Net/WebRequest.cs
 ../referencesource/System/net/System/Net/WebResponse.cs
index e76039084e77486fac483bcd9e5327aff78ed021..1503b6c92a39a6f643db30af6f3dee17e0c31984 100644 (file)
@@ -143,7 +143,6 @@ System.Net/BasicClient.cs
 System.Net/BindIPEndPoint.cs
 System.Net/ChunkStream.cs
 System.Net/ChunkedInputStream.cs
-System.Net/CredentialCache.cs
 System.Net/DecompressionMethods.cs
 System.Net/DefaultCertificatePolicy.cs
 System.Net/DigestClient.cs
@@ -157,7 +156,6 @@ System.Net/FtpRequestCreator.cs
 System.Net/FtpStatus.cs
 System.Net/FtpWebRequest.cs
 System.Net/FtpWebResponse.cs
-System.Net/GlobalProxySelection.cs
 System.Net/HttpConnection.cs
 System.Net/HttpListener.cs
 System.Net/HttpListenerBasicIdentity.cs
@@ -192,7 +190,6 @@ System.Net/WebConnection.cs
 System.Net/WebConnectionData.cs
 System.Net/WebConnectionGroup.cs
 System.Net/WebConnectionStream.cs
-System.Net/WebProxy.cs
 System.Net.WebSockets/ClientWebSocket.cs
 System.Net.WebSockets/ClientWebSocketOptions.cs
 System.Net.WebSockets/HttpListenerWebSocketContext.cs
@@ -292,6 +289,7 @@ Mono.Net.Security/MonoTlsStream.cs
 Mono.Net.Security/NoReflectionHelper.cs
 Mono.Net.Security/SystemCertificateValidator.cs
 
+ReferenceSources/AutoWebProxyScriptEngine.cs
 ReferenceSources/AssertWrapper.cs
 ReferenceSources/CAPI.cs
 ReferenceSources/EnvironmentHelpers.cs
@@ -300,11 +298,11 @@ ReferenceSources/Internal.cs
 ReferenceSources/HttpSysSettings.cs
 ReferenceSources/Logging.cs
 ReferenceSources/NativeMethods.cs
+ReferenceSources/RequestCacheProtocol.cs
 ReferenceSources/SettingsSectionInternal.cs
 ReferenceSources/Socket.cs
 ReferenceSources/SR.cs
 ReferenceSources/SRCategoryAttribute.cs
-ReferenceSources/SystemNetworkCredential.cs
 ReferenceSources/Win32Exception.cs
 
 ../referencesource/System/regex/system/text/regularexpressions/Regex.cs
@@ -681,6 +679,7 @@ ReferenceSources/Win32Exception.cs
 
 ../referencesource/System/net/System/Net/_BufferOffsetSize.cs
 ../referencesource/System/net/System/Net/_Connection.cs
+../referencesource/System/net/System/Net/_emptywebproxy.cs
 ../referencesource/System/net/System/Net/_HeaderInfo.cs
 ../referencesource/System/net/System/Net/_HeaderInfoTable.cs
 ../referencesource/System/net/System/Net/_HTTPDateParse.cs
@@ -690,9 +689,12 @@ ReferenceSources/Win32Exception.cs
 ../referencesource/System/net/System/Net/_LoggingObject.cs
 ../referencesource/System/net/System/Net/_ProxyChain.cs
 ../referencesource/System/net/System/Net/_ScatterGatherBuffers.cs
+../referencesource/System/net/System/Net/_TimerThread.cs
+../referencesource/System/net/System/Net/_WebProxyDataBuilder.cs
 ../referencesource/System/net/System/Net/AuthenticationScheme.cs
 ../referencesource/System/net/System/Net/AuthenticationSchemeSelector.cs
 ../referencesource/System/net/System/Net/Authorization.cs
+../referencesource/System/net/System/Net/CredentialCache.cs
 ../referencesource/System/net/System/Net/cookie.cs
 ../referencesource/System/net/System/Net/cookiecollection.cs
 ../referencesource/System/net/System/Net/cookiecontainer.cs
@@ -702,6 +704,7 @@ ReferenceSources/Win32Exception.cs
 ../referencesource/System/net/System/Net/FtpStatusCode.cs
 ../referencesource/System/net/System/Net/filewebrequest.cs
 ../referencesource/System/net/System/Net/filewebresponse.cs
+../referencesource/System/net/System/Net/GlobalProxySelection.cs
 ../referencesource/System/net/System/Net/HttpListenerException.cs
 ../referencesource/System/net/System/Net/HttpListenerRequestUriBuilder.cs
 ../referencesource/System/net/System/Net/HttpRequestHeader.cs
@@ -717,6 +720,7 @@ ReferenceSources/Win32Exception.cs
 ../referencesource/System/net/System/Net/IPEndPoint.cs
 ../referencesource/System/net/System/Net/IPHostEntry.cs
 ../referencesource/System/net/System/Net/iwebproxy.cs
+../referencesource/System/net/System/Net/IWebProxyFinder.cs
 ../referencesource/System/net/System/Net/IWebRequestCreate.cs
 ../referencesource/System/net/System/Net/NetworkAccess.cs
 ../referencesource/System/net/System/Net/ProtocolViolationException.cs
@@ -731,6 +735,7 @@ ReferenceSources/Win32Exception.cs
 ../referencesource/System/net/System/Net/WebExceptionStatus.cs
 ../referencesource/System/net/System/Net/WebHeaderCollection.cs
 ../referencesource/System/net/System/Net/WebPermission.cs
+../referencesource/System/net/System/Net/webproxy.cs
 ../referencesource/System/net/System/Net/WebRequestMethods.cs
 ../referencesource/System/net/System/Net/WebRequest.cs
 ../referencesource/System/net/System/Net/WebResponse.cs
index bf14c31bb37fcbd5bbd47fce4837c044c3e5a689..198f982db9c73f74a80beb4919dd0311dbfb230d 100644 (file)
@@ -120,6 +120,10 @@ using System.Configuration;
 #if MONO
     class RequestCacheValidator
     {
+        public object CreateValidator ()
+        {
+            throw new NotImplementedException ();
+        }
     }
 
     class RequestCachingSectionInternal
index 10dc8ecfd041a6d45227801b00f950d7217d8ad2..e890c070c092c147f5ba45ed0835fc04401bec86 100644 (file)
@@ -24,6 +24,7 @@ namespace System.Net {
     using System.Net.NetworkInformation;
     using System.Runtime.Serialization;
     using Microsoft.Win32;
+    using System.Collections.Generic;
 
     internal static class IntPtrHelper {
         /*
@@ -172,7 +173,6 @@ namespace System.Net {
         private static volatile IPAddress[] _LocalAddresses;
         private static object _LocalAddressesLock;
 
-#if MONO_NOT_IMPLEMENTED
 #if !FEATURE_PAL
 
         private static volatile NetworkAddressChangePolled s_AddressChange;
@@ -285,6 +285,19 @@ namespace System.Net {
         }
 
 #else // !FEATURE_PAL
+
+        internal static bool IsAddressLocal(IPAddress ipAddress) {
+            IPAddress[] localAddresses = NclUtilities.LocalAddresses;
+            for (int i = 0; i < localAddresses.Length; i++)
+            {
+                if (ipAddress.Equals(localAddresses[i], false))
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
         private const int HostNameBufferLength = 256;
         internal static string _LocalDomainName;
 
@@ -293,6 +306,9 @@ namespace System.Net {
         //
         private static IPHostEntry GetLocalHost()
         {
+#if MONO
+            return Dns.GetHostByName (Dns.GetHostName ());
+#else
             //
             // IPv6 Changes: If IPv6 is enabled, we can't simply use the
             //               old IPv4 gethostbyname(null). Instead we need
@@ -335,6 +351,7 @@ namespace System.Net {
 
                 return Dns.NativeToHostEntry(nativePointer);
             }
+#endif
 
         } // GetLocalHost
 
@@ -400,7 +417,6 @@ namespace System.Net {
             }
         }
 #endif // !FEATURE_PAL
-#endif
 
         private static object LocalAddressesLock
         {
index 8e2baeecb44e38ca3a1548e55e157da666ea4f56..8567a6861f23536a6ae894576ebfb6a071ceb293 100644 (file)
@@ -50,9 +50,7 @@ namespace System.Net {
 #endif // FEATURE_PAL
         private static volatile ArrayList s_PrefixList;
         private static Object s_InternalSyncObject;
-#if !MONO
         private static TimerThread.Queue s_DefaultTimerQueue = TimerThread.CreateQueue(DefaultTimeout);
-#endif
 
 #if !FEATURE_PAL
         private  AuthenticationLevel m_AuthenticationLevel;
@@ -60,10 +58,8 @@ namespace System.Net {
 #endif
 
         private RequestCachePolicy      m_CachePolicy;
-#if !MONO
         private RequestCacheProtocol    m_CacheProtocol;
         private RequestCacheBinding     m_CacheBinding;
-#endif
 
 #region designer support for System.Windows.dll
         internal class DesignerWebRequestCreate : IWebRequestCreate
@@ -95,13 +91,11 @@ namespace System.Net {
             }
         }
 
-#if !MONO
         internal static TimerThread.Queue DefaultTimerQueue {
             get {
                 return s_DefaultTimerQueue;
             }
         }
-#endif
 
         /*++
 
@@ -653,9 +647,6 @@ namespace System.Net {
 
 
         void InternalSetCachePolicy(RequestCachePolicy policy){
-#if MONO
-            throw new NotImplementedException ();
-#else
             // Delayed creation of CacheProtocol until caching is actually turned on.
             if (m_CacheBinding != null &&
                 m_CacheBinding.Cache != null &&
@@ -668,7 +659,6 @@ namespace System.Net {
             }
 
             m_CachePolicy = policy;
-#endif
         }
 
 
@@ -993,7 +983,6 @@ namespace System.Net {
             throw ExceptionHelper.MethodNotImplementedException;
         }
 
-#if !MONO
         //
         //
         //
@@ -1008,7 +997,6 @@ namespace System.Net {
                 m_CacheProtocol = value;
             }
         }
-#endif
 
 #if !FEATURE_PAL
         //
index ebdb2d6b3ebc3130dcdaf889cde3aaa9a76f3874..c68a3138212522f89ec07ed32286b5fc00761fd3 100644 (file)
@@ -187,7 +187,7 @@ namespace System.Net
         }
     }
 
-#if !MONO
+
     // This class implements failover logic for proxy scripts.
     internal class ProxyScriptChain : ProxyChain
     {
@@ -277,5 +277,4 @@ namespace System.Net
             return true;
         }
     }
-#endif
 }
index 059e88d5bcde16c8e502e603def82720c600ed11..c75a7136694cc52e0e2a78f7a3675fb631d843df 100644 (file)
@@ -182,7 +182,9 @@ namespace System.Net {
 
         static TimerThread() {
             s_ThreadEvents = new WaitHandle[] { s_ThreadShutdownEvent, s_ThreadReadyEvent };
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
             AppDomain.CurrentDomain.DomainUnload += new EventHandler(OnDomainUnload);
+#endif
         }
 
         /// <summary>
index ca05e1355e561793915794b0bdb735542ee2df37..dc7fdb26301b4cf69be900eb6bfd5857bb92cb6c 100644 (file)
@@ -414,7 +414,9 @@ namespace System.Net {
         /// </devdoc>
         [Obsolete("This method has been deprecated. Please use the proxy selected for you by default. http://go.microsoft.com/fwlink/?linkid=14202")]
         public static WebProxy GetDefaultProxy() {
+#if !DISABLE_CAS_USE
             ExceptionHelper.WebPermissionUnrestricted.Demand();
+#endif
             return new WebProxy(true);
         }
 
@@ -435,7 +437,9 @@ namespace System.Net {
             if (useRegistry) {
                 // just make the proxy advanced, don't populate with any settings
                 // note - this will happen in the context of the user performing the deserialization (their proxy settings get read)
+#if !DISABLE_CAS_USE
                 ExceptionHelper.WebPermissionUnrestricted.Demand();
+#endif
                 UnsafeUpdateFromRegistry();
                 return;
             }
@@ -497,6 +501,28 @@ namespace System.Net {
             }
         }
 
+#if MONO
+        public static IWebProxy CreateDefaultProxy ()
+        {
+#if MONOTOUCH
+            return Mono.Net.CFNetwork.GetDefaultProxy ();
+#elif MONODROID
+            // Return the system web proxy.  This only works for ICS+.
+            var data = AndroidPlatform.GetDefaultProxy ();
+            if (data != null)
+                return data;
+#else
+            if (Platform.IsMacOS) {
+                var data = Mono.Net.CFNetwork.GetDefaultProxy ();
+                if (data != null)
+                    return data;
+            }
+#endif
+
+            return new WebProxy (true);
+        }
+#endif
+
         // This constructor is used internally to make WebProxies that read their state from the registry.
         // 
         internal WebProxy(bool enableAutoproxy)
@@ -515,7 +541,7 @@ namespace System.Net {
         internal void UnsafeUpdateFromRegistry() {
             GlobalLog.Assert(!_UseRegistry, "WebProxy#{0}::UnsafeUpdateFromRegistry()|_UseRegistry ScriptEngine#{1}", ValidationHelper.HashString(this), ValidationHelper.HashString(m_ScriptEngine));
             _UseRegistry = true;
-#if !FEATURE_PAL
+#if !FEATURE_PAL || !MOBILE
             ScriptEngine = new AutoWebProxyScriptEngine(this, true);
             WebProxyData webProxyData = ScriptEngine.GetWebProxyData();