- Add some arg validation to match existing CurlHandler
- Change some names to be consistent with CurlHandler
- Use expression-bodied syntax in a few places
- Ensure only one handler is published in the face of race conditions
Commit migrated from https://github.com/dotnet/corefx/commit/56e96a6841f1bdef5756dc886ec24028fd9576ee
The current behavior for .NET Core (Windows, *Nix, and UAP) is to use a
default HTTP version if none or an illegal version is specified.
On .NET Framework, an exception is thrown in these cases, "Only HTTP/1.0
and HTTP/1.1 version requests are currently supported." This error
message wouldn't make sense now anyways since HTTP/2 is supported in
.NET Core. So, it is better to use a default version than to throw an
exception.
This difference between .NET Core and .NET Framework will be document
here:
https://github.com/dotnet/corefx/wiki/ApiCompatFixesdotnet/corefx#7878
Commit migrated from https://github.com/dotnet/corefx/commit/693f6dacd3b60af2b2ace76872e5644dcc03b68c
This file had never been formatted according to CoreFx style guidelines
when the code was first ported into GitHub.
Now that we are doing NETStandard2.0 work, I wanted to clean up this
file to avoid distractions as I add features.
Commit migrated from https://github.com/dotnet/corefx/commit/e92a6a087acb32f37fa7628cc92c76903733f73d
The HttpClientHandler for UAP does not properly implement the PreAuthenticate
property. This is because on UAP, HttpClientHandler is built on the WinRT
APIs which in turn are built on WinInet. And WinInet always uses authentication
caching internally and this results in the net effect of PreAuthenticate always
being "true".
The default for .NET Framework and .NET Core (non-UAP) is "false".
When this property was first added to .NET Core 1.1, the UAP version defaulted
to true and the setter would throw PNSE.
As part of .NET Core 2.0, API surface for networking APIs was expanded. This
resulted in HttpWebRequest exposing and implementing a "PreAuthenticate" property,
which is what it has historically done in .NET Framework. On .NET Core, HttpWebRequest
is built on top of HttpClient. And so, HttpWebRequest was enhanced in .NET Core 2.0
to set the default of PreAuthenticate to false. But this later caused the PNSE
exception to surface and this exception was caught in UWP app-compat testing.
Essentially, we had now created the default HttpWebRequest to always throw an
exception.
So, in PR dotnet/corefx#18105, the PNSE in HttpClientHandler.PreAuthenticate was commented out
and thus the setter became a no-op.
This PR basically acknowledges this situation and removes the TODO from this change.
Since there is no good way to implement the actual HttpClientHandler.PreAuthenticate
property, I left the getter default to return "true" which is closer to reality of
what happens on UAP (even though this default value is different from .NET Framework
or the rest of .NET Core). And, in terms of the setter for the property, I opted to
leave it as a no-op. This seems like the best compromise outcome for now and will
generate less distraction for developers rather than throwing an exception all the
time.
The rest of this PR moves the ActiveIssue's from the class level to the method level
as part of eventually solving all of them. In addition, I added a new test case to
validate the HttpClientHandler constructor defaults that are different on the UAP
platform.
Fixesdotnet/corefx#18104
Commit migrated from https://github.com/dotnet/corefx/commit/c3b2f15d90972a5607415582681584965f16c01d
- Apply IDE simplifications for things like null checks during assignments
- Fix GetOrAdd calls to only allocate if necessary
- Use throw expressions in a few places
- Add some readonlys to fields
- Change some .Waits to .GetAwaiter().GetResult()s
- Remove some unnecessary abstract overrides
- Remove some unnecessary usings
Commit migrated from https://github.com/dotnet/corefx/commit/dc01adf473ae5031be436808bf4b310c364c4268
The primary purpose of the PR is to get the code into the repo (not enabled by default), so most PR feedback is being left for subsequent PRs. However, this commit addresses the feedback deemed imperative to fix prior to initial merge.
Commit migrated from https://github.com/dotnet/corefx/commit/5c86b5e5e1a6896e0be396a6422e8f3ebed78648
After my PR dotnet/corefx#21325, I discovered an edge case where we need to check for
a non-null Proxy property in the underlying WebRequest.
On .NET Framework, System.Net.Http is built on WebRequest
(HttpWebRequest) and is subject to side-affects from it. The static
property WebRequest.DefaultWebProxy affects the initial value of
WebRequest.Proxy. So, it's possible that a developer may have set
WebRequest.DefaultWebProxy to null prior to using System.Net.Http in the
app.
The net affect of this is that that won't be any proxy used as the
system default proxy and thus the
HttpClientHandler.DefaultProxyCredentials is ignored.
On .NET Core, there is no relationship between System.Net.Http and
System.Net.WebRequest. So, in all cases on .NET Core, where a developer
has specified HttpClientHander.UseProxy=true and HttpClientHandler.Proxy
= null (default values), the handler will always try to use the system
default proxy (if configured).
Commit migrated from https://github.com/dotnet/corefx/commit/eac755df47f70e5ef3853c0b71ed4ab12455bb96
- Add a ManagedHandler field to both the Windows and Unix HttpClientHandler builds, and change the members to switch based on which is being used. The default is still to use WinHttpHandler and CurlHandler respectively, but setting an environment variable prior to constructing an HttpClientHandler will switch it to use ManagedHandler.
- Add test classes that will run the tests again but with the managed handler. Some of the test classes are commented out due to current failures.
- Fixed a few tests.
Commit migrated from https://github.com/dotnet/corefx/commit/b238d0d760a2588513c443f3a4c991222fd037bb
This bug was discovered in internal testing when this code was being
ported to .NET Framework vNext. Due to all these tests being previously
disabled on NETFX, the bug was missed.
The HttpClientHandler.DefaultProxyCredentials property is only used when
an explicit proxy is not specified (HttpClientHandler.Proxy==null) but a
proxy is still desired (HttpClientHandler.UseProxy==true). In this case,
the semantics implied are to use the system default proxy settings to
find a proxy. In that case, the credentials specified by
DefaultProxyCredentials should be passed to the webrequest.Proxy object
which, by default, points to the system proxy.
Commit migrated from https://github.com/dotnet/corefx/commit/e5306b55c0267c0369e5da9bef0467d2ea4e9b51
This change to enable remote execution of all corefx tests in UAP. Because the remote execution code for UAP is using WinRT APIs and to avoid forcing adding UAP configuration to all test projects, we factor the remote execution code into its own test library (called TestHelper) which is cross compiled.
Commit migrated from https://github.com/dotnet/corefx/commit/eb2f543b189e8f7f9ae4c31e832ac9d3c22bb41a