Commit Graph
1515 Commits
Author SHA1 Message Date
Tomas Weinfurt 95c2db6208 use HttpStatusCode.OK instead of cast to (int)200
Commit migrated from https://github.com/dotnet/corefx/commit/db8d62691f619841fbc46ebbbefe48fbc3f2a4aa
2018-02-15 16:30:52 -08:00
Tomas Weinfurt 25ea6021dc take feedback from review
Commit migrated from https://github.com/dotnet/corefx/commit/009a855ef809128cc3824b2a1f06a5e89cb867d0
2018-02-15 16:30:52 -08:00
Tomas Weinfurt aefcab1eaf address some comments from reviews. more to come. loopback tests still needs some work.
Commit migrated from https://github.com/dotnet/corefx/commit/36c8886b4c2526b4d9f11310a1a2dbd4aa991194
2018-02-15 16:28:20 -08:00
Tomas Weinfurt eba42b5b4e initial connect support
Commit migrated from https://github.com/dotnet/corefx/commit/6865bc83d06b632a326d4d60dc3cfc7ad4177c37
2018-02-15 16:10:09 -08:00
Geoff Kizer ea61dedad9 Merge pull request dotnet/corefx#27151 from geoffkizer/sslproxytunnel
SocketsHttpHandler: refactor pool manager logic to enable SSL proxy tunneling support

Commit migrated from https://github.com/dotnet/corefx/commit/6e3bcbec17273cd38db67e47e7a2975a25160ac2
2018-02-15 13:39:32 -08:00
Stephen Toub 96239ef682 Streamline SocketHttpHandler's ParseStatusLine validation (dotnet/corefx#27163)
* Streamline SocketHttpHandler's ParseStatusLine validation

For a typical status line like "HTTP/1.1 200 OK", cuts the time of ParseStatusLine almost in half.

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/c8d23b4941b3b620633db397a0094f55b01be22b
2018-02-15 16:04:40 -05:00
Stephen Toub b47f6bd40f Fix race condition in PostAsyncExpect100Continue_RetryOnConnectionClosed_Success test (dotnet/corefx#27148)
Commit migrated from https://github.com/dotnet/corefx/commit/28799e8af0556efe1b9e5e98b700460951ae9eb2
2018-02-15 14:59:30 -05:00
Geoff Kizer ab1edffdc0 address review feedback
Commit migrated from https://github.com/dotnet/corefx/commit/46785d3ae61987ae8ae389b2138645e82b54efb0
2018-02-15 10:55:32 -08:00
Tomas Weinfurt 5d8c6a618a disable two tests on ubuntu 18 while investigating root casue (dotnet/corefx#27144)
Commit migrated from https://github.com/dotnet/corefx/commit/d00eb7ec42434b0a7e2c3b4f6cd88c896ebaa30f
2018-02-15 05:47:50 -05:00
Geoff Kizer 76301c7104 add code to establish proxy tunnel for SSL
Commit migrated from https://github.com/dotnet/corefx/commit/d84a28844502bcf30538a18e30e33118ca879467
2018-02-14 18:43:15 -08:00
Geoff Kizer 6d6f3b6a0b reorganize pool manager logic and rework HttpConnectionKey to support ssl proxy tunneling
Commit migrated from https://github.com/dotnet/corefx/commit/39ed24e9f6f55d6077742776e154ead199e1b3a0
2018-02-14 18:25:38 -08:00
Geoff Kizer cc2e02b853 Merge pull request dotnet/corefx#27088 from geoffkizer/refactorloopbackserver
reorganize and cleanup some LoopbackServer code

Commit migrated from https://github.com/dotnet/corefx/commit/46267c1dbe46f0127e670ce25933ff49a5ec9d6e
2018-02-14 11:13:34 -08:00
Jeremy Barton ffe1b07233 Add FixedTimeEquals and other crypto helper routines as public API
Commit migrated from https://github.com/dotnet/corefx/commit/3872bafe8186a3e74cb66efa4a2835d60ed67ba2
2018-02-14 07:33:30 -08:00
Geoff Kizer 29cb5540c4 fix tests from merge
Commit migrated from https://github.com/dotnet/corefx/commit/b028092ce1af45e109edb0609b7b8cef42ee8a99
2018-02-13 16:04:27 -08:00
Geoff Kizer bf6635fcfd add response generation overloads
Commit migrated from https://github.com/dotnet/corefx/commit/6943fc7c0e92359e6335a618f6ff5ee8402af4ac
2018-02-13 16:04:26 -08:00
Geoff Kizer c9a61b410b address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/6ab005635528a03daa52ca727a4a74dcc0316830
2018-02-13 15:44:00 -08:00
Geoff Kizer b94eefba0f reorganize and cleanup some LoopbackServer code
Commit migrated from https://github.com/dotnet/corefx/commit/ec6a7215bb28a061d2357d8c3874447bc575132d
2018-02-13 15:43:59 -08:00
Caesar Chen 8bdfd2f594 Change HTTP default request version to HTTP/2 (dotnet/corefx#27079)
* change http default request version

* fix innerloop test


Commit migrated from https://github.com/dotnet/corefx/commit/f7a852f64bf20889579be70710f386a8d4802a34
2018-02-13 15:24:22 -08:00
Stephen Toub 8f3ddb7597 Enable SocketsHttpHandler cancellation support (dotnet/corefx#27029)
* Enable SocketsHttpHandler cancellation support

This change significantly improves the cancellation support in SocketsHttpHandler.  Previously we were passing the CancellationToken around to every method, eventually bottoming out in calls to the underlying Stream which then ends up passing them down to the underlying Socket.  But today Socket's support for cancellation is minimal, only doing up-front checks; if cancellation is requested during the socket operation rather than before, the request will be ignored.  Since HttpClient implements features like timeouts on top of cancellation support, it's important to do better than this.

The change implements cancellation by registering with the CancellationToken to dispose of the connection.  This will cause any reads/writes to wake up.  We then translate resulting exceptions into cancellation exceptions.  When in the main SendAsync method, we register once for the whole body of the operation until the point that we're returning the response message.  For individual operations on the response content stream, we register per operation; however, when feasible we try to avoid the registration costs by only registering if operations don't complete synchronously.  We also account for the case that on Unix, closing the connection may result in read operations waking up not with an exception but rather with EOF, which we also need to translate into cancellation when appropriate.

Along the way I cleaned up a few minor issues as well.

I also added a bunch of cancellation-related tests:
- Test cancellation occurring while sending request content
- Test cancellation occurring while receiving response headers
- Test cancellation occurring while receiving response body and using a buffered operation
- Test that all of the above are triggerable with CancellationTokenSource.Cancel, HttpClient.CancelPendingRequests, and HttpClient.Dispose
- Test cancellation occurring while receiving response body and using an unbuffered operation, either a ReadAsync or CopyToAsync on the response stream
- Test that a CancelPendingRequests doesn't affect unbuffered operations on the response stream

There are deficiencies here in the existing handlers, and tests have been selectively disabled accordingly (I also fixed a couple cases that naturally fell out of the changes I was making for SocketsHttpHandler).  SocketsHttpHandler passes now for all of them.

* Add test that Dispose doesn't cancel response stream


Commit migrated from https://github.com/dotnet/corefx/commit/53be85c2fe473fdea8c001e3d9fd81dd478b858e
2018-02-13 16:30:34 -05:00
Stephen Toub 62912af578 Fix SocketsHttpHandler connection pool accounting for dropped connections (dotnet/corefx#27068)
When MaxConnectionsPerServer is set to anything other than int.MaxValue, the SocketsHttpHandler pool keeps track of the number of connections handed out, and this count is updated when a connection is disposed.  But if a response stream isn't disposed of, resulting in the connection never being disposed of, the count may never be updated.  This fix adds an HttpConnection derived type that simply adds a finalizer, making it pay-for-play when MaxConnectionsPerServer is set to something other than the default.

Commit migrated from https://github.com/dotnet/corefx/commit/ffa5db357252913c52e0cdad63c1573020185f6e
2018-02-13 08:38:32 -05:00
Stephen Toub f8e6f41b81 Clear initlocals in a bunch of assemblies (dotnet/corefx#26993)
* Clear initlocals in a bunch of assemblies

Sets
```XML
<ILLinkClearInitLocals>true</ILLinkClearInitLocals>
```
for the assemblies:
    - System.IO.FileSystem
    - System.IO.Pipes
    - System.Memory
    - System.Net.Http
    - System.Net.Http.WinHttpHandler
    - System.Net.NameResolution
    - System.Net.NetworkInformation
    - System.Net.Primitives
    - System.Net.Requests
    - System.Net.Security
    - System.Net.Sockets
    - System.Net.WebSockets
    - System.Net.WebSockets.Client
    - System.Net.WebSockets.WebSocketsProtocol
    - System.Private.Uri
    - System.Runtime
    - System.Runtime.Extensions

Eventually we'd ideally set the flag for the whole repo; these are just the ones I audited thus far.  In a few cases I had to make code changes to adapt, where the code was expecting stackallocs to be cleared.  I also looked at a few other projects (System.Collections, System.Runtime.Numerics) where there were more significant dependencies on clearing and I decided to leave those for later.

* Disable ILLinkClearInitLocals running on Unix until it works there


Commit migrated from https://github.com/dotnet/corefx/commit/f0a032e4a1c8a848574a5db3e69e8a6fa0aae91e
2018-02-13 06:30:25 -05:00
Geoff Kizer b250d954d3 Merge pull request dotnet/corefx#27069 from stephentoub/cachessl
Cache SslClientAuthenticationOptions on SocketsHttpHandler pool

Commit migrated from https://github.com/dotnet/corefx/commit/a438733f09a739bfbd4b9f945ba049386858019a
2018-02-12 23:11:11 -08:00
Max Kerr 717083f0d4 Clear Authorization Headers on Redirect (dotnet/corefx#26864)
When a user has added an Authorization header to a request via the HttpClient DefaultRequestHeaders Authorization field, ensure that header is stripped on redirect.

This change adds a method to strip Authorization headers that were set via the HttpClient DefaultRequestHeaders Authorization field, and calls that method on redirect. In addition, it adds a test to ensure that this behavior occurs as expected.

The new method ResetAuthRequestHeaders is based on the method ResetCookieRequestHeaders, which is used to reset cookie headers on redirect.

The issue also occurs in CurlHandler, but the fix is slightly different. Rather than remove the headers that have already been set, we can instead just skip them when copying over the new headers to the redirected request.

Fixes dotnet/corefx#26426

Commit migrated from https://github.com/dotnet/corefx/commit/7e6396b2bcb4d372b199cfb7b3b13e290c441124
2018-02-12 11:28:09 -08:00
Stephen Toub d1e0b0b1bd Fix HttpClientMiniStress.UnreadResponseMessage_Collectible test (dotnet/corefx#27061)
The async state machine was holding a reference to the response content object, which in turn prevented the response stream from being collected.

Commit migrated from https://github.com/dotnet/corefx/commit/6c9b62981190ae5886196f37d0f5dc614f4b0244
2018-02-12 13:39:02 -05:00
Stephen Toub 35aa72b9a7 Cache SslClientAuthenticationOptions on SocketsHttpHandler pool
For the common case, we can just use a singleton cached instance with settings computed when the pool is created.  Only if it's accessed via HttpClientHandler with a server certificate callback do we need to still create an instance per request, in order to wrap the delegate to provide the expected semantics.


Commit migrated from https://github.com/dotnet/corefx/commit/911d4aff095f1c8648334d4a221c217cd09e466b
2018-02-12 12:17:33 -05:00
Geoff Kizer a8ffcf7322 fix stress response generation, and disable failing test (dotnet/corefx#27059)
Commit migrated from https://github.com/dotnet/corefx/commit/472c3d95749910ba600df296bbf01d78d7c4f6d8
2018-02-12 07:25:24 -05:00
Stephen Toub ee5f5d76a1 Tweak CurlHandler SSL not supported messages to be more helpful (dotnet/corefx#27043)
* Tweak CurlHandler SSL not supported messages to be more helpful

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/9cde3e174b2495cbcdf95995aea0bea4030d4aa9
2018-02-12 05:27:57 -05:00
Geoff Kizer 2927c099bf Merge pull request dotnet/corefx#26989 from geoffkizer/fixcookiehandling
SocketsHttpHandler: Fix some issues with cookie handling, and add cookie tests

Commit migrated from https://github.com/dotnet/corefx/commit/8cee267154ef9dc6dde7a76a828844a200437872
2018-02-11 18:23:50 -08:00
Geoff Kizer e4d9a6c5c8 fix tests on netfx
Commit migrated from https://github.com/dotnet/corefx/commit/c7cc2a879d0a5b5f039caff36bef0c99f52604a2
2018-02-11 14:49:42 -08:00
Geoff Kizer ef25741e58 consolidate cookie tests
Commit migrated from https://github.com/dotnet/corefx/commit/c20262c69a93449498d511014e9e69bad18f987a
2018-02-11 12:38:20 -08:00
Stephen Toub 5c894d6b17 Add SocketsHttpHandler check for TransferEncodingChunked w/o Content (dotnet/corefx#27040)
Commit migrated from https://github.com/dotnet/corefx/commit/bf5a3183bc901723ebe0bb3d178bec86cda57429
2018-02-11 12:19:03 -05:00
Geoff Kizer f7a5007eaa address review feedback
Commit migrated from https://github.com/dotnet/corefx/commit/15beaca5f2062792bf4a2dd137a42d6e53f98e5e
2018-02-09 13:00:16 -08:00
Tomas Weinfurt 844d6893d1 minimal support for ManagedHandler proxy configuration on Windows (dotnet/corefx#26878)
* initial implementation 

Commit migrated from https://github.com/dotnet/corefx/commit/468db63e2648f8a4c0c82d97e301e308b7887f7e
2018-02-09 12:05:30 -08:00
Geoff Kizer 5a05ac3821 rework cookie logic to address issues and remove CookieHandler
Commit migrated from https://github.com/dotnet/corefx/commit/7d11d419421cc9bea0b8fa3d186bb6a406cd3a4b
2018-02-09 00:45:09 -08:00
Geoff Kizer 3a5fbcf1c2 add protocol tests for cookie handling
Commit migrated from https://github.com/dotnet/corefx/commit/750b29bbb1433ad5d4c3727217192dddbef90eef
2018-02-09 00:37:09 -08:00
Caesar Chen 1717bb7f67 Disable Http status line test cases on CurlHandler (dotnet/corefx#26982)
Commit migrated from https://github.com/dotnet/corefx/commit/6730463bd0bb1a65e679b8a6643d611b69086b29
2018-02-08 20:54:34 -08:00
Stephen Toub 296015a364 Add more SocketsHttpHandler tests
Commit migrated from https://github.com/dotnet/corefx/commit/8cb4d130bc3e8151fc72fe9494787643c7b00c4b
2018-02-08 19:12:50 -05:00
Stephen Toub 89dfde815e Expose SocketsHttpHandler
- Renames ManagedHandler to SocketsHttpHandler
- Moves a bunch of files around accordingly
- Updates System.Net.WebSockets.Client to use SocketsHttpHandler directly
- Updates System.Net.Http's tests with a reflection-based rather than TLS-based method for instantiating an HttpClientHandler backed by a SocketsHttpHandler.


Commit migrated from https://github.com/dotnet/corefx/commit/852d40e723c849e8d0c486676d40332343e12ca5
2018-02-08 19:12:50 -05:00
Stephen Toub 4597cdf7e3 Ensure EventData structs in EventSource implementations are zero'd (dotnet/corefx#26968)
In preparation for clearing initlocals.

Commit migrated from https://github.com/dotnet/corefx/commit/f3e7e18b4baa70adeb0ba9a02d80d3acf0f796e3
2018-02-08 17:42:43 -05:00
Caesar Chen 3c4000f401 Enable HttpProtocolTest status line test cases (dotnet/corefx#26798)
* enable all test data

* seperate test data

* add one missing data

* address pr feedabck

* address feedback

* disable test by active issue & add else clause


Commit migrated from https://github.com/dotnet/corefx/commit/426e1c72a0dbda1aece127ec5f56696dc465d74b
2018-02-08 09:18:21 -08:00
Stephen Toub c8c6ae416a Switch ManagedHandler to use SslClientAuthenticationOptions (dotnet/corefx#26870)
Simplifies the public ManagedHandler API by using the now existing SslClientAuthenticationOptions bag as a way to pass in all of the SSL-related options.  This also means we start enabling anything already on SslClientAuthenticationOptions as well as anything new added in the future, without requiring new API on ManagedHandler.

In the process of doing that, also added an implemention of HttpClientHandler.ClientCertificateOption for ManagedHandler; previously Automatic was just ignored.

I also removed UseDefaultCredentials from ManagedHandler, as it's ignored and not relevant until additional auth mechanisms are supported.

Commit migrated from https://github.com/dotnet/corefx/commit/ee7d4599ed8ac2bca796cc7627ebf33b75f8b7cb
2018-02-07 19:36:53 -05:00
Stephen Toub 458c3f858c Implement MaxResponseHeadersLength on ManagedHandler (dotnet/corefx#26906)
Commit migrated from https://github.com/dotnet/corefx/commit/b6b7eb09600c18d35c6f9bf9ca484d5b8399f718
2018-02-07 17:58:05 -05:00
Geoff Kizer 9c26603fa8 address review feedback
Commit migrated from https://github.com/dotnet/corefx/commit/7b9be1d656ecba48fdb4082b37a66574c3172a4e
2018-02-07 10:54:12 -08:00
Geoff Kizer 1296d2b3fd add test for connection upgrade
Commit migrated from https://github.com/dotnet/corefx/commit/61eb7b2667465dcc6e4c52829a505d74e51adc4a
2018-02-07 10:54:11 -08:00
Stephen Toub 601553e06d Add Connection{Idle}Timeouts to ManagedHandler (dotnet/corefx#26839)
* Add Connection{Idle}Timeouts to ManagedHandler

We can agree on the final name(s) when going through API reviews.  For now, I chose what I think are easy to understand names:
- ConnectionTimeout: how long a connection is allowed to be reused before it's no longer usable, defaults to infinite
- ConnectionIdleTimeout: how long a connection can sit idle in the pool before it's no longer usable, defaults to 2 minutes (that value was hardcoded before this change)

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/1a5cdbe1af7a5befe16bb4581f29f0af64f4a101
2018-02-07 07:51:10 -05:00
Geoff Kizer 507363f7c1 Merge pull request dotnet/corefx#26782 from geoffkizer/httpmisc2
ManagedHandler: support LF line endings and trailer headers

Commit migrated from https://github.com/dotnet/corefx/commit/ddf2a6d45973d5ceb6b2c9920a23f64094c6da3c
2018-02-07 00:12:58 -08:00
Paulo Janotti 99eb957292 Proper check for OpenSSL version in System.Net.Http.Tests (dotnet/corefx#26873)
Disable the tests affected by dotnet/corefx#26803 in the correct way so tests are skipped only when needed.

Commit migrated from https://github.com/dotnet/corefx/commit/cd26075ef0d371e222ab52a1322ea9a73f07ad72
2018-02-05 21:43:37 -08:00
Paulo Janotti d88807b6d4 Conditionally skip test causing assert in WSL. (dotnet/corefx#26875)
Skip test in WSL until dotnet/corefx#26813 and dotnet/corefx#26476 are fixed

Commit migrated from https://github.com/dotnet/corefx/commit/d9665c946e47dc9a3cf4b4669d73f9d49a752a68
2018-02-05 21:40:59 -08:00
Geoff Kizer e220972236 clean up encoding handling
Commit migrated from https://github.com/dotnet/corefx/commit/3d2f149c5891ee9095de2b50877676b903002147
2018-02-05 11:09:59 -08:00
Dan Moseley 623ba89344 Disable Http test for 26770 (dotnet/corefx#26854)
Commit migrated from https://github.com/dotnet/corefx/commit/8c3ac0912ef40ae98835f3188fa75605210253a8
2018-02-05 10:58:56 -08:00