* Fix HttpClient redirection logic on UAP
This PR changes the implementation of sending requests in HttpClient for UAP when
dealing with redirection. In the past, we would let the WinRT layer handle auto
redirection logic. However, due to dotnet/corefx#9003, the cookies were getting lost on 3xx responses
since the .NET layer didn't see them. So, this PR implements the redirection ourselves.
One important part of redirection is that we need to drop credentials. The WinRT layer
did this for us. However, we are unable to use a single WinRT HttpBaseProtocolFilter object
since we need to remove the credential after the first redirect. So, we need to maintain
a second filter that uses no credentials and keep it in sync regarding all the other properties
of the primary filter.
With this PR, the behavior of other aspects (such as controlling max number of redirects, etc.)
now matches .NET Framework. So, some tests were adjusted to remove the UAP specific behavior
checks.
Fixesdotnet/corefx#9003Fixesdotnet/corefx#22191
* Disable test on Linux
* Address PR feedback
* Disable failing HTTP/2 test
Commit migrated from https://github.com/dotnet/corefx/commit/f2308f8db0679ac63e8e7eeac9d56cb035d6d9e3
ManagedHandler_HttpClientHandler_ConnectionPooling_Test didn't assert
IDisposable (though did have a Dispose method), so it didn't clear the
environment variable that says to use the prototype managed handler in tests.
This means that any tests which should still be using the curl provider end up
using the managed provider until another managed test runs.
So now it's disposable, and a failure we were expecting, but not seeing, on
macOS 10.13 is asserting itself again.
Commit migrated from https://github.com/dotnet/corefx/commit/3dac2dbf20a56e6b525e078e977bfeed3ae8de8a
LibreSSL needs locks initialized in order to be used safely from
multiple threads, which happens when multiple HttpClients are used. But
we don't currently have a good way to perform that initialization as we
do for OpenSSL. As a workaround, add a shared MultiAgent that's
initialized when LibreSSL is used on macOS, and use that same MultiAgent
from all CurlHandler instances rather than giving each their own. Since
MultiAgent is 1:1 with a thread, all HttpClient's will then end up
sharing the same libcurl event loop thread, and we'll serialize all of
our interactions with libcurl and thus hopefully with LibreSSL.
Commit migrated from https://github.com/dotnet/corefx/commit/a26de495ffa390a9d6b3a0d0f338e9d9f97ad5fe
* Reconcile behavior of MaxRequestContentBufferSize across .NET Core
The HttpClientHandler property, MaxRequestContentBufferSize, has been
deprecated. This PR reconciles the behavior of the getter and setter of
the property.
Similar to other decisions in HttpClient PRs with these kinds of
behavior differences, we are not going to throw PNSE. We will document
the differences in the AppCompat docs.
Fixesdotnet/corefx#7879
* Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/e740973fed660da4426218bf2ec4be35a60ad095
* Re-enable anf fix Http tests for UAP
* Removed ActiveIssue from a bunch of Http tests.
* Converted some ActiveIssue to SkipOnTargetFramework due to
platform differences.
* Change some tests to use RemoteInvoke to get process isolation
since UAP will cache connections per-process.
* Removed a duplicate ChannelBinding test. There is already the
same test in HttpClientHandlerTest.ServerCertificates.cs
(PostAsync_Post_ChannelBinding_ConfiguredCorrectly). And that
test checks more things.
Contributes to dotnet/corefx#20010
* Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/a3cd07a7b608358710ac073cbe41f65866aa929a
* Fix HttpClientHandler UAP to use a filtered set of client certs
My earlier PR dotnet/corefx#22022 refactored the GetEligibleClientCertificates code
into a Common method. However, I neglected to actually use it in the UAP
HttpClientHandler!
Fixed the handler to properly filter down the set of client
certificates.
Added new tests to verify functionality. While doing this, I discovered
that the tests need to run in an isolated process due to the per-process
caching behavior of the UAP HTTP stack.
So, I used the RemoteInvoke method. I had to duplicate some of the new
tests using Fact instead of using Theory. This is because the
RemoteInvoke doesn't allow non-string parameters and I had to pass
in X509Certificate2 objects. So, I separated out each variant into its
own Fact test.
* Address PR feedback
* Fix code refactoring to properly filter client certificates.
* Fix test names in nameof() blocks.
* Disable a test from using the managed handler.
* Address PR feedback
* Remove unneeded using statements.
* Disable managed handler in some SslProtocols tests.
Commit migrated from https://github.com/dotnet/corefx/commit/9c4af2973699aea35ce5c60c00f7dd14398e7a14
* Implement client certificates for HttpClient on UAP
Added code for HttpClientHandler.ClientCertificates on UAP.
Moved code duplicated in several places into a common helper class, CertificateHelper.
Then I discovered a bug introduced into GetEligibleCertificates (from PR dotnet/corefx#21908) that
doesn't properly filter by EKU or KeyUsage if there is only one cert (this was failing
the WinHttpHandler Unit tests). So, I removed that optimization.
Used the new Azure test endpoint for client certificates. I did not use the loopback
server because there is a problem using it with HttpClient in UAP. There is a crash
in the SslStream.AuthenticateAsServer that I was not able to diagnose yet. It will
require a lot of time debugging and I wanted to get this HttpClientHandler feature
done now. Tracking that investigation with dotnet/corefx#22021.
Fixesdotnet/corefx#21628
Contributes to dotnet/corefx#14542
* Address PR feedback
* Moved method to Windows-only Common file
* Fixed some line spacing
Other potential refactoring/optimizations will be looked into in dotnet/corefx#22045
Commit migrated from https://github.com/dotnet/corefx/commit/472b8d8ec212c2afb107dea305b4624c4989a79f
* Fix HttpClientHandler ServerCertificateCustomValidationCallback for UWP
This PR implements the ServerCertificateCustomValidationCallback for UWP. While implementing this, I discovered that the behavior of
the current .NET Core code is incorrect regarding how to propagate exceptions from the user provided callback. I opened up a new
issue dotnet/corefx#21904 and revised the test as well.
Fixesdotnet/corefx#21627
* Address more PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/e30fdc38e60f6fa2ed8e7e103d1f8c44655438cd