Skip to content

Commit 781a316

Browse files
authored
Merge pull request dotnet#31678 from dotnet-maestro-bot/merge/release/2.1-to-release/2.2
[automated] Merge branch 'release/2.1' => 'release/2.2'
2 parents e4a9643 + 2f00d0b commit 781a316

File tree

8 files changed

+72
-7
lines changed

8 files changed

+72
-7
lines changed

src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public HttpConnectionPool(HttpConnectionPoolManager poolManager, HttpConnectionK
110110
Debug.Assert(port != 0);
111111
Debug.Assert(sslHostName == null);
112112
Debug.Assert(proxyUri != null);
113-
Debug.Assert(proxyUri.IdnHost == host && proxyUri.Port == port);
114113
break;
115114

116115
default:

src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpEnvironmentProxy.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,18 @@ private static Uri GetUriFromString(string value)
227227
else
228228
{
229229
host = value.Substring(0, separatorIndex);
230-
if (!UInt16.TryParse(value.AsSpan(separatorIndex + 1), out port))
230+
int endIndex = separatorIndex + 1;
231+
// Strip any trailing characters after port number.
232+
while (endIndex < value.Length)
233+
{
234+
if (!char.IsDigit(value[endIndex]))
235+
{
236+
break;
237+
}
238+
endIndex += 1;
239+
}
240+
241+
if (!ushort.TryParse(value.AsSpan(separatorIndex + 1, endIndex - separatorIndex - 1), out port))
231242
{
232243
return null;
233244
}

src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpSystemProxy.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ private HttpSystemProxy(WinInetProxyHelper proxyHelper, SafeWinHttpHandle sessio
6666

6767
if (proxyHelper.ManualSettingsOnly)
6868
{
69+
if (NetEventSource.IsEnabled) NetEventSource.Info(proxyHelper, $"ManualSettingsUsed, {proxyHelper.Proxy}");
6970
ParseProxyConfig(proxyHelper.Proxy, out _insecureProxyUri, out _secureProxyUri);
71+
if (_insecureProxyUri == null && _secureProxyUri == null)
72+
{
73+
// If advanced parsing by protocol fails, fall-back to simplified parsing.
74+
_insecureProxyUri = _secureProxyUri = GetUriFromString(proxyHelper.Proxy);
75+
}
7076

7177
if (!string.IsNullOrWhiteSpace(proxyHelper.ProxyBypass))
7278
{

src/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,18 @@ public async Task Dispose_DisposingHandlerCancelsActiveOperationsWithoutResponse
21802180
return;
21812181
}
21822182

2183+
if (PlatformDetection.IsFullFramework)
2184+
{
2185+
// Skip test on .NET Framework. It will sometimes not throw TaskCanceledException.
2186+
// Instead it might throw the following top-level and inner exceptions depending
2187+
// on race conditions.
2188+
//
2189+
// System.Net.Http.HttpRequestException : Error while copying content to a stream.
2190+
// ---- System.IO.IOException : The read operation failed, see inner exception.
2191+
//-------- System.Net.WebException : The request was aborted: The request was canceled.
2192+
return;
2193+
}
2194+
21832195
await LoopbackServer.CreateServerAsync(async (server1, url1) =>
21842196
{
21852197
await LoopbackServer.CreateServerAsync(async (server2, url2) =>
@@ -2658,8 +2670,10 @@ public async Task PostAsync_Redirect_LargePayload_Helper(int statusCode, bool ex
26582670
}
26592671
}
26602672

2661-
[OuterLoop] // TODO: Issue #11345
2662-
[Theory, MemberData(nameof(EchoServers))] // NOTE: will not work for in-box System.Net.Http.dll due to disposal of request content
2673+
[OuterLoop("Uses external server")]
2674+
[Theory, MemberData(nameof(EchoServers))]
2675+
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, ".NET Framework disposes request content after send")]
2676+
[ActiveIssue(31104, TestPlatforms.AnyUnix)]
26632677
public async Task PostAsync_ReuseRequestContent_Success(Uri remoteServer)
26642678
{
26652679
const string ContentString = "This is the content string.";

src/System.Net.Http/tests/UnitTests/HttpEnvironmentProxyTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ public void HttpProxy_EnvironmentProxy_Loaded()
112112
[InlineData("domain\\foo:bar@1.1.1.1", "1.1.1.1", "80", "foo", "bar")]
113113
[InlineData("domain%5Cfoo:bar@1.1.1.1", "1.1.1.1", "80", "foo", "bar")]
114114
[InlineData("HTTP://ABC.COM/", "abc.com", "80", null, null)]
115+
[InlineData("http://10.30.62.64:7890/", "10.30.62.64", "7890", null, null)]
116+
[InlineData("http://1.2.3.4:8888/foo", "1.2.3.4", "8888", null, null)]
115117
public void HttpProxy_Uri_Parsing(string _input, string _host, string _port, string _user , string _password)
116118
{
117119
RemoteInvoke((input, host, port, user, password) =>

src/System.Net.Http/tests/UnitTests/HttpSystemProxyTest.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,29 @@ public void HttpProxy_SystemProxy_Loaded(string rawProxyString, bool hasInsecure
6464
}, rawProxyString, hasInsecureProxy.ToString(), hasSecureProxy.ToString()).Dispose();
6565
}
6666

67+
[Theory]
68+
[InlineData("localhost:1234", "http://localhost:1234/")]
69+
[InlineData("123.123.123.123", "http://123.123.123.123/")]
70+
public void HttpProxy_SystemProxy_Loaded(string rawProxyString, string expectedUri)
71+
{
72+
RemoteInvoke((proxyString, expectedString) =>
73+
{
74+
IWebProxy p;
75+
76+
FakeRegistry.Reset();
77+
78+
FakeRegistry.WinInetProxySettings.Proxy = proxyString;
79+
WinInetProxyHelper proxyHelper = new WinInetProxyHelper();
80+
81+
Assert.True(HttpSystemProxy.TryCreate(out p));
82+
Assert.NotNull(p);
83+
Assert.Equal(expectedString, p.GetProxy(new Uri(fooHttp)).ToString());
84+
Assert.Equal(expectedString, p.GetProxy(new Uri(fooHttps)).ToString());
85+
86+
return SuccessExitCode;
87+
}, rawProxyString, expectedUri).Dispose();
88+
}
89+
6790
[Theory]
6891
[InlineData("http://localhost/", true)]
6992
[InlineData("http://127.0.0.1/", true)]
@@ -144,7 +167,6 @@ public void HttpProxy_Local_Parsing(string bypass, int count)
144167
[InlineData("http://;")]
145168
[InlineData("http=;")]
146169
[InlineData(" ; ")]
147-
[InlineData("proxy.contoso.com")]
148170
public void HttpProxy_InvalidSystemProxy_Null(string rawProxyString)
149171
{
150172
RemoteInvoke((proxyString) =>

src/System.Net.Requests/src/System/Net/HttpWebRequest.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,11 +1138,22 @@ private async Task<WebResponse> SendRequest()
11381138

11391139
Debug.Assert(handler.UseProxy); // Default of handler.UseProxy is true.
11401140
Debug.Assert(handler.Proxy == null); // Default of handler.Proxy is null.
1141+
1142+
// HttpClientHandler default is to use a proxy which is the system proxy.
1143+
// This is indicated by the properties 'UseProxy == true' and 'Proxy == null'.
1144+
//
1145+
// However, HttpWebRequest doesn't have a separate 'UseProxy' property. Instead,
1146+
// the default of the 'Proxy' property is a non-null IWebProxy object which is the
1147+
// system default proxy object. If the 'Proxy' property were actually null, then
1148+
// that means don't use any proxy.
1149+
//
1150+
// So, we need to map the desired HttpWebRequest proxy settings to equivalent
1151+
// HttpClientHandler settings.
11411152
if (_proxy == null)
11421153
{
11431154
handler.UseProxy = false;
11441155
}
1145-
else
1156+
else if (!object.ReferenceEquals(_proxy, WebRequest.GetSystemWebProxy()))
11461157
{
11471158
handler.Proxy = _proxy;
11481159
}

tools-local/ILAsmVersion.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.3-servicing-26724-06
1+
2.1.3-servicing-26724-06

0 commit comments

Comments
 (0)