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

add back parsing for simple configuration #31314

Merged
merged 3 commits into from
Jul 24, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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 advance parsing by protocol fails, fall-back to simplified parsing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: advanced

_insecureProxyUri = _secureProxyUri = GetUriFromString(proxyHelper.Proxy);
}

if (!string.IsNullOrWhiteSpace(proxyHelper.ProxyBypass))
{
Expand Down
22 changes: 21 additions & 1 deletion src/System.Net.Http/tests/UnitTests/HttpSystemProxyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ public void HttpProxy_SystemProxy_Loaded(string rawProxyString, bool hasInsecure
}, rawProxyString, hasInsecureProxy.ToString(), hasSecureProxy.ToString()).Dispose();
}

[Theory]
[InlineData("localhost:1234")]
[InlineData("123.123.123.123")]
public void HttpProxy_SystemProxy_Loaded(string rawProxyString)
{
RemoteInvoke((proxyString) =>
{
IWebProxy p;

FakeRegistry.Reset();

FakeRegistry.WinInetProxySettings.Proxy = proxyString;
WinInetProxyHelper proxyHelper = new WinInetProxyHelper();

Assert.True(HttpSystemProxy.TryCreate(out p));
Assert.NotNull(p);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of just Assert'ing for NotNull, you should Assert that the URI created is what you expected. I.e. from the rawProxyString="localhost:1234", you get "http://localhost:1234" etc. You would need to add the expected URI string as an additional InlineData parameter.


return SuccessExitCode;
}, rawProxyString).Dispose();
}

[Theory]
[InlineData("http://localhost/", true)]
[InlineData("http://127.0.0.1/", true)]
Expand Down Expand Up @@ -144,7 +165,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