static ServicePointManager ()
{
+#if NET_2_0 && CONFIGURATION_DEP
+ object cfg = ConfigurationManager.GetSection (configKey);
+ ConnectionManagementSection s = cfg as ConnectionManagementSection;
+ if (s != null) {
+ manager = new ConnectionManagementData (null);
+ foreach (ConnectionManagementElement e in s.ConnectionManagement)
+ manager.Add (e.Address, e.MaxConnection);
+
+ return;
+ }
+#endif
manager = (ConnectionManagementData) ConfigurationSettings.GetConfig (configKey);
}
+
// Constructors
private ServicePointManager ()
{
RecycleServicePoints ();
bool usesProxy = false;
+ bool useConnect = false;
if (proxy != null && !proxy.IsBypassed(address)) {
usesProxy = true;
+ bool isSecure = address.Scheme == "https";
address = proxy.GetProxy (address);
- if (address.Scheme != "http" && address.Scheme != "https")
+ if (address.Scheme != "http" && !isSecure)
throw new NotSupportedException ("Proxy scheme not supported.");
+
+ if (isSecure && address.Scheme == "http")
+ useConnect = true;
}
address = new Uri (address.Scheme + "://" + address.Authority);
ServicePoint sp = null;
lock (servicePoints) {
- sp = servicePoints [address] as ServicePoint;
+ int key = address.GetHashCode () + (int) ((useConnect) ? 1 : 0);
+ sp = servicePoints [key] as ServicePoint;
if (sp != null)
return sp;
sp.UseNagleAlgorithm = useNagle;
#endif
sp.UsesProxy = usesProxy;
- servicePoints.Add (address, sp);
+ sp.UseConnect = useConnect;
+ servicePoints.Add (key, sp);
}
return sp;