Commit Graph
1267 Commits
Author SHA1 Message Date
Stephen Toub 5f18995584 Improve connection pooling in ManagedHandler
Add support for purging stale connections from the pool and for a max number of connections per server.


Commit migrated from https://github.com/dotnet/corefx/commit/b52ad56a22e4bfabb55adc166396e1221b0e75f6
2017-07-19 23:28:54 -04:00
Stephen Toub a162c3892c Skip assert in Http SSL test on macOS (dotnet/corefx#22305)
Commit migrated from https://github.com/dotnet/corefx/commit/bb455945e6afe35d1b705c3590decdbcbfba5e5f
2017-07-18 11:42:35 -04:00
Stephen Toub fc393e88e9 Assert more details in Http SSL test failure (dotnet/corefx#22303)
Commit migrated from https://github.com/dotnet/corefx/commit/7d7a7efb58a49638e48c560631633730e10674dc
2017-07-15 22:54:00 -04:00
Lakshmi Priya Sekar f828d320fd Disable incompatible test on macos high sierra.
Commit migrated from https://github.com/dotnet/corefx/commit/c6afac0fb789e93431e3940e1ed08a2eabd3c344
2017-07-14 11:09:25 -07:00
Jeremy Barton 993c772595 Make ManagedHandler ConnectionPoolingTest clean itself up (dotnet/corefx#22267)
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
2017-07-14 12:49:38 -04:00
David Shulman 0e9da04ab9 Port TFS WinRT interop tests for HttpClient for UAP (dotnet/corefx#22239)
* Port TFS WinRT interop tests for HttpClient for UAP

Bring over the last of the WinRT interop tests for HttpClient. These
tests deal with interop between WinRT stream classes and .NET stream
classes.

Fixes dotnet/corefx#9044

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/7f4b8837ef77c3784cde0f57d17a5e656df86cb4
2017-07-14 09:01:11 -07:00
Stephen Toub bdc7e48e00 Use a shared MultiAgent in CurlHandler when using LibreSSL backend on macOS (dotnet/corefx#22242)
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
2017-07-13 21:48:10 -04:00
David Shulman 247c84a48c Reconcile behavior of MaxRequestContentBufferSize across .NET Core (dotnet/corefx#22201)
* 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.

Fixes dotnet/corefx#7879

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/e740973fed660da4426218bf2ec4be35a60ad095
2017-07-13 13:21:41 -07:00
David Shulman b85affb0a9 Adjust Http tests for UAP behavior differences (dotnet/corefx#22193)
Made changes to some UAP tests due to known platform differences.
Differences will be documented in the AppCompat docs.

Opened some new issues for bugs to investigate.

Fixes dotnet/corefx#22159
Fixes dotnet/corefx#22163

Commit migrated from https://github.com/dotnet/corefx/commit/1db009972e87bcdb719954bb6b00e19e67f4860b
2017-07-12 19:17:28 -07:00
David Shulman 9441d0365a Re-enable and fix Http tests for UAP (dotnet/corefx#22155)
* 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
2017-07-12 13:26:01 -07:00
David Shulman 113a821137 Fix HttpClientHandler UAP to use a filtered set of client certs (dotnet/corefx#22075)
* 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
2017-07-11 16:39:00 -07:00
David Shulman 823f81b56e Implement client certificates for HttpClient on UAP (dotnet/corefx#22022)
* 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.

Fixes dotnet/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
2017-07-10 16:52:07 -07:00
Stephen Toub ac9303e990 Disable GetAsync_UnsupportedSSLVersion_Throws test on Linux
Commit migrated from https://github.com/dotnet/corefx/commit/0b3134f7b9a2b2be73dcbfa0deca7a8da24d6621
2017-07-09 00:50:15 -04:00
David Shulman 465f5b4426 Modify some HttpClient tests to use RemoteInvoke on UAP (dotnet/corefx#22000)
* Modify some HttpClient tests to use RemoteInvoke on UAP

A few of the HttpClient tests were failing and needed to be isolated into their
own process. This is due to the UAP stack using per-process connection pooling.

Fixes dotnet/corefx#21945

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/69424bfe32417870a5b3047bad4958cc7fa5d9a8
2017-07-08 10:53:30 -07:00
Stephen Toub e4e0f8e85d Disable ManagedHandler negative test failing on older Windows 10 builds (dotnet/corefx#22002)
Commit migrated from https://github.com/dotnet/corefx/commit/99aa82499ef8fe11e6049a6ba2a636eb8780a520
2017-07-08 00:55:57 -04:00
Stephen Toub b9696b910b Avoid substring allocations for number parsing (dotnet/corefx#21990)
This both avoids substring allocations and is faster than the current calls, at least in microbenchmarks.

Commit migrated from https://github.com/dotnet/corefx/commit/1e16bbac85e83a38f6508abd790cb7d6b3b38db9
2017-07-07 23:57:25 -04:00
Stephen Toub 2fdaa3a056 Avoid forcing response general headers allocation in ConnectionClose
Commit migrated from https://github.com/dotnet/corefx/commit/64540b9bbd698929f9378a5cc6964982963ae9b2
2017-07-07 11:30:10 -04:00
Stephen Toub 220d3bc4f0 Ammortize IdnHost allocations by storing it in HttpConnection
Commit migrated from https://github.com/dotnet/corefx/commit/0d05ea15f1ea5cf384c504f070179376586510fd
2017-07-07 09:09:40 -04:00
Geoff Kizer 3468cf76fb handle Connection: close on response
Commit migrated from https://github.com/dotnet/corefx/commit/5b5fb9f525e97afceeece3be3131f5f60ada55c5
2017-07-07 08:39:46 -04:00
Stephen Toub 783d69cc63 Use pending ReadAsync in ManagedHandler to detect closed connections (dotnet/corefx#21936)
Commit migrated from https://github.com/dotnet/corefx/commit/dc379629280346ddadd6ccbcc879833347271214
2017-07-07 07:32:40 -04:00
David Shulman 729e5773e4 Fix HttpClientHandler ServerCertificateCustomValidationCallback for UWP (dotnet/corefx#21905)
* 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.

Fixes dotnet/corefx#21627

* Address more PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/e30fdc38e60f6fa2ed8e7e103d1f8c44655438cd
2017-07-06 17:22:50 -07:00
Stephen Toub abcb513dde Fix ManagedHandler to support connecting to IPv6 servers (dotnet/corefx#21951)
Also use IdnHost instead of Host, in case the Host isn't DNS-safe.

Commit migrated from https://github.com/dotnet/corefx/commit/45ae10c713f9799f2f47a2c390b30529bd222bac
2017-07-06 16:37:32 -04:00
Stephen Toub da8094f0e5 Wrap CurlHandler cert validation callback exceptions in HttpRequestException (dotnet/corefx#21938)
* Wrap CurlHandler cert validation callback exceptions in HttpRequestException

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/9d74fcf4534894f375caebe20bfe62dd7af7fbd0
2017-07-06 16:37:20 -04:00
Stephen Toub 14de90821d Disable several ManagedHandler tests (dotnet/corefx#21907)
These were enabled as they weren't failing CI, but that's likely because they were being skipped rather than because they actually work.

Commit migrated from https://github.com/dotnet/corefx/commit/4a9d2b80677eb4e51892873b9dafe1fedfaeae22
2017-07-05 19:16:35 -04:00
Stephen Toub 9a99800209 Several test fixes to unblock failing tests
Commit migrated from https://github.com/dotnet/corefx/commit/a910d82cab99072c89746761d77b231c88ed5790
2017-07-05 14:02:33 -04:00
Stephen Toub 6a3070c094 Don't fail when there's no status description
Or when the status code doesn't have a known status description.


Commit migrated from https://github.com/dotnet/corefx/commit/a031a3b5d4199fe92efd9a7785fa67a79cafc53d
2017-07-05 12:43:12 -04:00
Stephen Toub 5f28d7f42c Enable most of ManagedHandler_HttpClientHandlerTest tests
Explicitly disabled a few that are failing.  We'll need to revisit those subsequently, but this at least gets most of the tests running.


Commit migrated from https://github.com/dotnet/corefx/commit/2179ea079abb5c15aeb0387c7e52ab25b8503713
2017-07-05 12:43:12 -04:00
Stephen Toub ba9c884896 Enable ManagedHandler_HttpClientMiniStress tests
One test needed to be fixed to deal with the fact that currently the ManagedHandler doesn't throttle connections and can end up getting denied connection errors from the server when exceeding the listen backlog size employed.


Commit migrated from https://github.com/dotnet/corefx/commit/47ffa8b49cf3d04be888f4d1e1dc287cdcbbe5e5
2017-07-05 12:43:12 -04:00
Stephen Toub f58d8f73a2 Add missing ManagedHandler derived test classes
I missed these when adding the derived types.


Commit migrated from https://github.com/dotnet/corefx/commit/c11593e8204d9ea8a664352dfef09b7d4edae4a2
2017-07-05 12:43:12 -04:00
Stephen Toub fd63714f4a Re-enable ManagedHandler_HttpClientHandler_ClientCertificates_Test and ManagedHandler_HttpClientHandler_ServerCertificates_Test
The tests that verify PNSEs getting thrown were failing incorrectly when the managed handler was used on platforms like CentOS where our CI system has an old libcurl installed.  For now, I've worked around it in a very manual fashion, but longer term we need a better way of using the same tests against multiple handlers substituted dynamically.


Commit migrated from https://github.com/dotnet/corefx/commit/fb2f2e8be64d6bf2c26030ef63d1e5cb004e8a64
2017-07-05 12:43:12 -04:00
Stephen Toub 0fac064c51 Enable ManagedHandler_HttpClientHandler_SslProtocols_Test tests
These are all passing now.


Commit migrated from https://github.com/dotnet/corefx/commit/17fc1976a479cd8977fb935bf2067f432d8d5db4
2017-07-05 12:43:12 -04:00
Stephen Toub 0b13c63547 Enable ManagedHandler_SchSendAuxRecordHttpTest tests
The managed client was more sensitive to timing issues resulting from the server not properly closing the connection.


Commit migrated from https://github.com/dotnet/corefx/commit/938e31584ba70a4272ac83b2fdf781d5d8cdc659
2017-07-05 12:43:12 -04:00
Stephen Toub ffec43fde5 Prevent SslProvider exceptions from being thrown to native code (dotnet/corefx#21801)
* Prevent SslProvider exceptions from being thrown to native code

CurlHandler.SslProvider register the VerifyCertChain method to be invoked by OpenSSL in order to validate a cert chain.  If the validation code throws an exception from certain places, e.g. in response to OpenSSL reporting unknown cipher suites, that exception is currently allowed to propagate out of the function back across the interop boundary, which is unsupported and results in bad behaviors.  The fix is to widen the existing catch block to catch all such exceptions and marshal them to the associated request appropriately.

* Add X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY to MapVerifyErrorToChainStatus

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/c4df8bdc5b2720294b83f44acd6501a89a3b638b
2017-07-05 12:14:49 -04:00
Lakshmi Priya Sekar cc7237e4bb Disable hostname check on macOS with non-SecureTransport backend. (dotnet/corefx#21841)
Commit migrated from https://github.com/dotnet/corefx/commit/3cb942288d3342592ad53ec2a213708ff72bcb24
2017-07-03 22:23:29 -07:00
Hugh Bellamy 98b18432b7 Move AssertExtensions to Corefx.Private.TestUtilities (dotnet/corefx#21799)
* Move AssertExtensions to Corefx.Private.TestUtilities

* Update csprojs

* Fix Linq.Expressions uapaot build


Commit migrated from https://github.com/dotnet/corefx/commit/7e3b0db2892c56a431f8e99af9cd9381adec385a
2017-07-03 09:27:30 -07:00
Stephen Toub c6dcdd5c5a Re-disable a few ManagedHandler tests
The condition for these tests needs to be adjusted.  The tests in question are verifying that a PNSE is thrown on platforms that don't have an OpenSSL backend, but that's irrelevant when using the managed handler, on which these tests actually successfully make connections rather than throwing.

Committing directly to unblock CI.

Commit migrated from https://github.com/dotnet/corefx/commit/4f9322825a9da4f47677b1413f0feabed3fd746b
2017-07-02 11:35:14 -04:00
Stephen Toub e0a5ae3073 Disable one test and clean up some TODOs
Commit migrated from https://github.com/dotnet/corefx/commit/9e97d0d8eb8e3d643bbf485a4ea758535c287dbd
2017-06-30 17:30:14 -04:00
Stephen Toub 849ab9a89b Separate ManagedHandlerTestHelpers into its own file
Commit migrated from https://github.com/dotnet/corefx/commit/083a1dc85c21ecb980e0af58f78af7af87254edd
2017-06-30 17:15:18 -04:00
Stephen Toub 8909da570e Fix several PostScenarioTest tests
Tests expect that IOExceptions and InvalidOperationExceptions from SendAsync are wrapped in HttpRequestExceptions.


Commit migrated from https://github.com/dotnet/corefx/commit/4ed7139a9755db8a1a1c50a1365d8ab15c66fd9a
2017-06-30 17:11:44 -04:00
Stephen Toub ca58a45b18 Fix SafeFreeContextBufferChannelBinding.ToString()
One of the Windows-only tests is expecting SslStream's ChannelBinding's ToString() to output the data from the binding in a specific format, matching what WinHttp's outputs.  This makes that happen.  And enables more tests.


Commit migrated from https://github.com/dotnet/corefx/commit/0cd7eeabb6b91c44827592bd45f8312dcb961388
2017-06-30 17:11:44 -04:00
Stephen Toub 96d042f9ab Fix handling of 0-byte reads
And re-enable some tests that were tripping over them.


Commit migrated from https://github.com/dotnet/corefx/commit/32b5f3e3fb8ae4611ac1b2edce11d54849ba19f2
2017-06-30 17:11:44 -04:00
Stephen Toub 55108cffa3 Merge pull request dotnet/corefx#21750 from stephentoub/fix_linux_tests
Enable a bunch of ManagedHandler tests

Commit migrated from https://github.com/dotnet/corefx/commit/3435cab26d7362169e8e19c2ec711d8126dc42db
2017-06-30 17:09:26 -04:00
Stephen Toub 112aba715d Enable a bunch of tests for ManagedHandler
Commit migrated from https://github.com/dotnet/corefx/commit/eeb86610d8bcb9b38733d57279baf93e9ae68274
2017-06-29 22:01:11 -04:00
Stephen Toub 3b4a6c1854 Add DefaultProxyCredentials support
Commit migrated from https://github.com/dotnet/corefx/commit/c4cec4291648936e84fb8ed06c705df259514be9
2017-06-29 21:56:56 -04:00
Stephen Toub b6ae9abdf1 Add initial support for http_proxy
Commit migrated from https://github.com/dotnet/corefx/commit/06bb29fee02d969e4efef970663235e7fde797bc
2017-06-29 21:43:05 -04:00
Cristian Pop 23a2417388 Tracking ETW UAP test failures against a single issue. Global mutex is not supported in UAP. (dotnet/corefx#21732)
* Removing Global mutex bug ID. Tracking ETW UAP test failures against a single issue.
* Disabling EKU tests for UAP.

Commit migrated from https://github.com/dotnet/corefx/commit/12632fd50d02c1b1934cac13edc8225304ac91a5
2017-06-29 16:22:14 -07:00
David Shulman 7fa3bc181b Merge pull request dotnet/corefx#21691 from davidsh/nocache_uwp
Fix HttpClientHandler on UAP to use WinRT NoCache enum

Commit migrated from https://github.com/dotnet/corefx/commit/e40c2be03a5a4690f187b19bdd97e5b9924f5578
2017-06-29 15:26:03 -07:00
Stephen Toub 85048fcbed Merge pull request dotnet/corefx#21679 from stephentoub/httpperf
Several allocation improvements for HttpClient/ManagedHandler

Commit migrated from https://github.com/dotnet/corefx/commit/6bf1e7c3032d3c24d5a41bbd880549ef4a8de2da
2017-06-29 13:34:58 -04:00
Stephen Toub 3fbe23325e Address PR feedback
- Alphabetize consts
- Remove ValueTask dependency from HttpClient/Content, as it causes issues for the netfx/net46 builds


Commit migrated from https://github.com/dotnet/corefx/commit/d2af4889d35d63e287f6c16cffee5baf58dd4925
2017-06-29 08:09:06 -04:00
David Shulman 9de4463148 Fix HttpClientHandler on UAP to use WinRT NoCache enum
Since System.Net.Http APIs default to not using any cache, we need to
turn off caching at the WinRT layer. If supported, we set the
CacheControl.ReadBehavior to use the NoCache enum value. Otherwise,
we use the next best enum option.

Removed some unneeded try/catch handling when we previously
needed to handle compiling with older SDKs and trap JIT error.
This is no longer needed for NETStandard20.

Fixed some typos from a previous PR.

Fixes dotnet/corefx#7877


Commit migrated from https://github.com/dotnet/corefx/commit/1cf87a19d450040a0ad53c5f9580c5f5ddadd4e1
2017-06-28 20:57:36 -07:00