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
#
--- /dev/null
+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
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) {
}
[Conditional ("TRACE")]
internal static void PrintWarning(TraceSource traceSource, string msg) {
}
+
+ [Conditional ("TRACE")]
+ internal static void PrintError(TraceSource traceSource, string msg) {
+ }
}
#if MOBILE
--- /dev/null
+namespace System.Net.Cache
+{
+ class RequestCacheProtocol
+ {
+ public RequestCacheProtocol (object arg1, object arg2)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
\ No newline at end of file
//
// 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";
}
+using System.Net.Security;
+
namespace System.Net.Configuration {
sealed class SettingsSectionInternal
{
#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; }
}
}
+++ /dev/null
-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
+++ /dev/null
-//
-// 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;
- }
- }
-}
-}
-
-
+++ /dev/null
-//
-// 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
- }
- }
- }
-}
{
this.requestUri = uri;
this.actualUri = uri;
- this.proxy = GlobalProxySelection.Select;
+ this.proxy = InternalDefaultWebProxy;
this.webHeaders = new WebHeaderCollection (WebHeaderCollectionType.HttpWebRequest);
ThrowOnError = true;
ResetAuthorization ();
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;
return;
}
- bool isProxy = ProxyQuery && !proxy.IsBypassed (actualUri);
+ bool isProxy = ProxyQuery && proxy != null && !proxy.IsBypassed (actualUri);
bool redirected;
try {
public static ServicePoint FindServicePoint (Uri address)
{
- return FindServicePoint (address, GlobalProxySelection.Select);
+ return FindServicePoint (address, null);
}
public static ServicePoint FindServicePoint (string uriString, IWebProxy proxy)
+++ /dev/null
-//
-// 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);
- }
- }
-}
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
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
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
Mono.Net.Security/NoReflectionHelper.cs
Mono.Net.Security/SystemCertificateValidator.cs
+ReferenceSources/AutoWebProxyScriptEngine.cs
ReferenceSources/AssertWrapper.cs
ReferenceSources/BinaryCompatibility.cs
ReferenceSources/ConfigurationManagerInternalFactory.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
../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
../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
../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
../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
../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
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
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
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
Mono.Net.Security/NoReflectionHelper.cs
Mono.Net.Security/SystemCertificateValidator.cs
+ReferenceSources/AutoWebProxyScriptEngine.cs
ReferenceSources/AssertWrapper.cs
ReferenceSources/CAPI.cs
ReferenceSources/EnvironmentHelpers.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
../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
../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
../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
../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
../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
#if MONO
class RequestCacheValidator
{
+ public object CreateValidator ()
+ {
+ throw new NotImplementedException ();
+ }
}
class RequestCachingSectionInternal
using System.Net.NetworkInformation;
using System.Runtime.Serialization;
using Microsoft.Win32;
+ using System.Collections.Generic;
internal static class IntPtrHelper {
/*
private static volatile IPAddress[] _LocalAddresses;
private static object _LocalAddressesLock;
-#if MONO_NOT_IMPLEMENTED
#if !FEATURE_PAL
private static volatile NetworkAddressChangePolled s_AddressChange;
}
#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;
//
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
return Dns.NativeToHostEntry(nativePointer);
}
+#endif
} // GetLocalHost
}
}
#endif // !FEATURE_PAL
-#endif
private static object LocalAddressesLock
{
#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;
#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
}
}
-#if !MONO
internal static TimerThread.Queue DefaultTimerQueue {
get {
return s_DefaultTimerQueue;
}
}
-#endif
/*++
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 &&
}
m_CachePolicy = policy;
-#endif
}
throw ExceptionHelper.MethodNotImplementedException;
}
-#if !MONO
//
//
//
m_CacheProtocol = value;
}
}
-#endif
#if !FEATURE_PAL
//
}
}
-#if !MONO
+
// This class implements failover logic for proxy scripts.
internal class ProxyScriptChain : ProxyChain
{
return true;
}
}
-#endif
}
static TimerThread() {
s_ThreadEvents = new WaitHandle[] { s_ThreadShutdownEvent, s_ThreadReadyEvent };
+#if MONO_FEATURE_MULTIPLE_APPDOMAINS
AppDomain.CurrentDomain.DomainUnload += new EventHandler(OnDomainUnload);
+#endif
}
/// <summary>
/// </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);
}
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;
}
}
}
+#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)
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();