Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
add back parsing for simple configuration (#31314) (#31367)
Browse files Browse the repository at this point in the history
* add back simplified proxy configuration
* add tracing
* feedback from review
  • Loading branch information
wfurt committed Aug 9, 2018
1 parent d6f8efc commit c6950db
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Expand Up @@ -66,7 +66,13 @@ private HttpSystemProxy(WinInetProxyHelper proxyHelper, SafeWinHttpHandle sessio

if (proxyHelper.ManualSettingsOnly)
{
if (NetEventSource.IsEnabled) NetEventSource.Info(proxyHelper, $"ManualSettingsUsed, {proxyHelper.Proxy}");
ParseProxyConfig(proxyHelper.Proxy, out _insecureProxyUri, out _secureProxyUri);
if (_insecureProxyUri == null && _secureProxyUri == null)
{
// If advanced parsing by protocol fails, fall-back to simplified parsing.
_insecureProxyUri = _secureProxyUri = GetUriFromString(proxyHelper.Proxy);
}

if (!string.IsNullOrWhiteSpace(proxyHelper.ProxyBypass))
{
Expand Down
24 changes: 23 additions & 1 deletion src/System.Net.Http/tests/UnitTests/HttpSystemProxyTest.cs
Expand Up @@ -64,6 +64,29 @@ public void HttpProxy_SystemProxy_Loaded(string rawProxyString, bool hasInsecure
}, rawProxyString, hasInsecureProxy.ToString(), hasSecureProxy.ToString()).Dispose();
}

[Theory]
[InlineData("localhost:1234", "http://localhost:1234/")]
[InlineData("123.123.123.123", "http://123.123.123.123/")]
public void HttpProxy_SystemProxy_Loaded(string rawProxyString, string expectedUri)
{
RemoteInvoke((proxyString, expectedString) =>
{
IWebProxy p;
FakeRegistry.Reset();
FakeRegistry.WinInetProxySettings.Proxy = proxyString;
WinInetProxyHelper proxyHelper = new WinInetProxyHelper();
Assert.True(HttpSystemProxy.TryCreate(out p));
Assert.NotNull(p);
Assert.Equal(expectedString, p.GetProxy(new Uri(fooHttp)).ToString());
Assert.Equal(expectedString, p.GetProxy(new Uri(fooHttps)).ToString());
return SuccessExitCode;
}, rawProxyString, expectedUri).Dispose();
}

[Theory]
[InlineData("http://localhost/", true)]
[InlineData("http://127.0.0.1/", true)]
Expand Down Expand Up @@ -144,7 +167,6 @@ public void HttpProxy_Local_Parsing(string bypass, int count)
[InlineData("http://;")]
[InlineData("http=;")]
[InlineData(" ; ")]
[InlineData("proxy.contoso.com")]
public void HttpProxy_InvalidSystemProxy_Null(string rawProxyString)
{
RemoteInvoke((proxyString) =>
Expand Down

0 comments on commit c6950db

Please sign in to comment.