2008-11-04 Gonzalo Paniagua Javier <gonzalo@novell.com>
[mono.git] / mcs / class / System / System.Net / ServicePointManager.cs
index 07db11f85873de104195aa530fe93db9722bc6e5..bea42e48cc30dfc838ff743830182e460c2e373c 100644 (file)
@@ -59,6 +59,37 @@ namespace System.Net
 {
        public class ServicePointManager
        {
+               class SPKey {
+                       Uri uri; // schema/host/port
+                       bool use_connect;
+
+                       public SPKey (Uri uri, bool use_connect) {
+                               this.uri = uri;
+                               this.use_connect = use_connect;
+                       }
+
+                       public Uri Uri {
+                               get { return uri; }
+                       }
+
+                       public bool UseConnect {
+                               get { return use_connect; }
+                       }
+
+                       public override int GetHashCode () {
+                               return uri.GetHashCode () + ((use_connect) ? 1 : 0);
+                       }
+
+                       public override bool Equals (object obj) {
+                               SPKey other = obj as SPKey;
+                               if (obj == null) {
+                                       return false;
+                               }
+
+                               return (uri.Equals (other.uri) && other.use_connect == use_connect);
+                       }
+               }
+
                private static HybridDictionary servicePoints = new HybridDictionary ();
                
                // Static properties
@@ -69,8 +100,13 @@ namespace System.Net
                private static int maxServicePoints = 0;
                private static bool _checkCRL = false;
                private static SecurityProtocolType _securityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
+
 #if NET_1_1
+#if TARGET_JVM
+               static bool expectContinue = false;
+#else
                static bool expectContinue = true;
+#endif
                static bool useNagle;
 #endif
 
@@ -92,10 +128,14 @@ namespace System.Net
                                foreach (ConnectionManagementElement e in s.ConnectionManagement)
                                        manager.Add (e.Address, e.MaxConnection);
 
+                               defaultConnectionLimit = (int) manager.GetMaxConnections ("*");                         
                                return;
                        }
 #endif
                        manager = (ConnectionManagementData) ConfigurationSettings.GetConfig (configKey);
+                       if (manager != null) {
+                               defaultConnectionLimit = (int) manager.GetMaxConnections ("*");                         
+                       }
                }
 
                // Constructors
@@ -137,23 +177,30 @@ namespace System.Net
                }
 
 #if NET_2_0
+               static Exception GetMustImplement ()
+               {
+                       return new NotImplementedException ();
+               }
+               
+               [MonoTODO]
                public static int DnsRefreshTimeout
                {
                        get {
-                               throw new NotImplementedException ();
+                               throw GetMustImplement ();
                        }
                        set {
-                               throw new NotImplementedException ();
+                               throw GetMustImplement ();
                        }
                }
                
+               [MonoTODO]
                public static bool EnableDnsRoundRobin
                {
                        get {
-                               throw new NotImplementedException ();
+                               throw GetMustImplement ();
                        }
                        set {
-                               throw new NotImplementedException ();
+                               throw GetMustImplement ();
                        }
                }
 #endif
@@ -193,14 +240,15 @@ namespace System.Net
                        set { _securityProtocol = value; }
                }
 
-#if NET_2_0
+#if NET_2_0 && SECURITY_DEP
+               [MonoTODO]
                public static RemoteCertificateValidationCallback ServerCertificateValidationCallback
                {
                        get {
-                               throw new NotImplementedException ();
+                               throw GetMustImplement ();
                        }
                        set {
-                               throw new NotImplementedException ();
+                               throw GetMustImplement ();
                        }
                }
 #endif
@@ -227,7 +275,7 @@ namespace System.Net
                {
                        return FindServicePoint (new Uri(uriString), proxy);
                }
-               
+
                public static ServicePoint FindServicePoint (Uri address, IWebProxy proxy)
                {
                        if (address == null)
@@ -252,7 +300,7 @@ namespace System.Net
                        
                        ServicePoint sp = null;
                        lock (servicePoints) {
-                               int key = address.GetHashCode () + (int) ((useConnect) ? 1 : 0);
+                               SPKey key = new SPKey (address, useConnect);
                                sp = servicePoints [key] as ServicePoint;
                                if (sp != null)
                                        return sp;