Fix HttpWebRequest when using system proxy settings (dotnet/corefx#31100)
authorDavid Shulman <david.shulman@microsoft.com>
Tue, 17 Jul 2018 02:51:03 +0000 (19:51 -0700)
committerGitHub <noreply@github.com>
Tue, 17 Jul 2018 02:51:03 +0000 (19:51 -0700)
commit94a31681446022ecac57b68f4cef12c4f0659f40
tree8284caa55b395206f26ade7c8874e08b90281965
parent00dc3461e0de93db0fbb844a8a10c94f1c6c6863
Fix HttpWebRequest when using system proxy settings (dotnet/corefx#31100)

While investigating other HttpClient/HttpWebRequest proxy-related bugs, I discovered that
HttpWebRequest was not honoring system proxy settings as defined on Windows with IE
settings or on Linux using environment variables.

The problem is due to how HttpClient and HttpWebRequest differ in how they represent
the default behavior of using system proxy settings with the various properties. Fixed
HttpWebRequest so that it will translate the system proxy settings to the internal
HttpClient/HttpClientHandler objects.

I also removed an invalid Assert in HttpConnection. This assert was firing when using a proxy
that was defined on the loopback adapter using IPv6 literal "[::1]".  Due to issue dotnet/corefx#28863 with Uri,
the Uri.IdnHost property doesn't have the brackets for IPv6 literals. So, the Assert was
occuring.

I did not add any new CI tests because it is currently not possible to test system proxy settings
in CI since it involves changing machine configuration. But I ran manual tests.

Commit migrated from https://github.com/dotnet/corefx/commit/72119235e294e711871cf453f2ffc66ba17ff23b
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.cs
src/libraries/System.Net.Requests/src/System/Net/HttpWebRequest.cs