Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2018-02-07 20:27:29 +0300
committerGitHub <noreply@github.com>2018-02-07 20:27:29 +0300
commita9e01da6f1b3a0dfbc36d17823a2264e2ec47050 (patch)
treeb83bf26c2817ddac7c61cc41a99cd6553660ee2c /src/System.Net.ServicePoint
parent1a5cdbe1af7a5befe16bb4581f29f0af64f4a101 (diff)
Fix ServicePointManager.ProxyAddressIfNecessary to ignore "system" proxy failures (#26925)
The whole ServicePointManager implementation is there just to make basic stuff not fail. But HttpWebRequest's Proxy defaults to an internal dummy singleton SystemWebProxy whose GetProxy method throws a PlatformNotSupportedException. Until we can clean that up and have a real proxy in place, we should just eat that PlatformNotSupportedException when the ServicePointManager calls GetProxy.
Diffstat (limited to 'src/System.Net.ServicePoint')
-rw-r--r--src/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs b/src/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs
index 5d0f21c44a..250c455aba 100644
--- a/src/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs
+++ b/src/System.Net.ServicePoint/src/System/Net/ServicePointManager.cs
@@ -176,16 +176,27 @@ namespace System.Net
{
if (proxy != null && !address.IsLoopback)
{
- Uri proxyAddress = proxy.GetProxy(address);
- if (proxyAddress != null)
+ try
{
- if (proxyAddress.Scheme != Uri.UriSchemeHttp)
+ Uri proxyAddress = proxy.GetProxy(address);
+ if (proxyAddress != null)
{
- throw new NotSupportedException(SR.Format(SR.net_proxyschemenotsupported, address.Scheme));
- }
+ if (proxyAddress.Scheme != Uri.UriSchemeHttp)
+ {
+ throw new NotSupportedException(SR.Format(SR.net_proxyschemenotsupported, address.Scheme));
+ }
- address = proxyAddress;
- return true;
+ address = proxyAddress;
+ return true;
+ }
+ }
+ catch (PlatformNotSupportedException)
+ {
+ // HttpWebRequest has a dummy SystemWebProxy that's used as a sentinel
+ // and whose GetProxy method throws a PlatformNotSupportedException.
+ // For the purposes of this stand-in ServicePointManager implementation,
+ // we ignore this default "system" proxy for the purposes of mapping
+ // to a particular ServicePoint instance.
}
}