Commit Graph
872 Commits
Author SHA1 Message Date
Stephen Toub a471023af9 Increase timeout on ConnectTimeout_TimesOutSSLAuth_Throws test (dotnet/corefx#27294)
Hopefully fixes dotnet/corefx#27291.  If it fails again, we'll need to look for a deeper reason than just CI hammering the server and causing things to take longer.

Commit migrated from https://github.com/dotnet/corefx/commit/7c3caab0801dc1542ab21c79fab2194a525c952f
2018-02-20 16:05:47 -05:00
Lakshmi Priya Sekar 548687e68b Merge pull request dotnet/corefx#26979 from Priya91/newhttpauth
Add test infra for auth testing.

Commit migrated from https://github.com/dotnet/corefx/commit/ff123e89989b2b34e82c854ea597626d884d52ba
2018-02-20 11:06:08 -08:00
Geoff Kizer 1ff27f16dd SocketsHttpHandler: Don't reuse connection with extraneous received data (dotnet/corefx#27265)
* don't reuse connection with extraneous received data

* add tracking issue


Commit migrated from https://github.com/dotnet/corefx/commit/5a57de7524fa3c3a2ba2b4f643f30464f917e14f
2018-02-20 08:20:20 -05:00
Geoff Kizer b17b24ae2d Merge pull request dotnet/corefx#27255 from geoffkizer/fixcl
SocketsHttpHandler: remove Content-Length header if Transfer-Encoding: chunked is present

Commit migrated from https://github.com/dotnet/corefx/commit/f9853fafb6e49c1c6e94f8c3130af9da4a1574a2
2018-02-19 22:07:37 -08:00
Geoff Kizer 98ff22b12c modify test to work around CL population issue
Commit migrated from https://github.com/dotnet/corefx/commit/ff5318905c9134d5fbf87b6597f72d331bc9a029
2018-02-19 11:28:15 -08:00
Stephen Toub 51b78a974c Implement SocketsHttpHandler's Expect100ContinueTimeout and ConnectTimeout (dotnet/corefx#27242)
With the expectation that we'll want to expose this in 2.1, implement Expect100ContinueTimeout and ConnectTimeout.  The members are currently internal but can be flipped public easily once the APIs are approved.  This also fixes an issue with cancellation around the connect phase, where a cancellation request that came in during the SSL auth phase would not be respected.

Commit migrated from https://github.com/dotnet/corefx/commit/01fa16ffd618846a913cad719269c8bb441ceb28
2018-02-19 11:06:18 -05:00
Caesar Chen 987d73a579 Enable SendReceive_VaryingLengthBuffers_Success on Windows run (dotnet/corefx#27181)
* enable test on Windows run

* delete script

* disable test issue dotnet/corefx#27211

* disable test see dotnet/corefx#27217


Commit migrated from https://github.com/dotnet/corefx/commit/d3a69ff4448a0bd4df12e6af481898825c066c67
2018-02-16 16:03:46 -08:00
Lakshmi Priya Sekar 130436c7f3 More test fixes from CI.
Commit migrated from https://github.com/dotnet/corefx/commit/3fe39953a3213f60110e319cef869958a9638c49
2018-02-16 11:24:15 -08:00
Stephen Toub b6b2da9344 Improve test coverage of SocketsHttpHandler (dotnet/corefx#27135)
* Improve test coverage of SocketsHttpHandler

Used code coverage information to write targeted tests to cover various uncovered paths in SocketsHttpHandler.  Along the way fixed a variety of issues relating to throwing the wrong exception type, a stack overflow due to an unexpected recursive call, etc.

* Address PR feedback

* Re-disable a test


Commit migrated from https://github.com/dotnet/corefx/commit/39677219aaeab8c6591b625ab2874acb17eaf4ef
2018-02-16 12:02:45 -05:00
Max Kerr cd85b45b2d Modify StreamContent to use default CopyToAsync buffer size when no size is provided (dotnet/corefx#27176)
* Add a tentative fix

* Minor fixes.

* Remove unused default value.

* Re-order error checks for compatibility reasons.

* Add a test to pin exception behavior when both parameters are incorrect.


Commit migrated from https://github.com/dotnet/corefx/commit/c28fbce3ce31cc0274b14e6e4ae08a84ec04ed1b
2018-02-16 07:18:59 -05:00
Lakshmi Priya Sekar 086a261943 More test fixes from CI runs.
Commit migrated from https://github.com/dotnet/corefx/commit/29374f83897d19995b640c1d663e68dfb9fb1058
2018-02-15 16:59:26 -08:00
Lakshmi Priya Sekar 29936a5929 Response to PR feedback.
Commit migrated from https://github.com/dotnet/corefx/commit/9721f49e0838a3b3355437cb1f6882d9d62ab557
2018-02-15 14:24:44 -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
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
Lakshmi Priya Sekar 4fc5a16b79 Mark failing tests with issue.
Commit migrated from https://github.com/dotnet/corefx/commit/828468a258cfba872c84c3976835e9c664f68dee
2018-02-14 17:24:03 -08:00
Lakshmi Priya Sekar 705c8ae243 Add tests to all handlers.
Commit migrated from https://github.com/dotnet/corefx/commit/aa2482155262063229ea3f0e5d868890d8490415
2018-02-14 15:52:54 -08:00
Lakshmi Priya Sekar 5f4349f7f0 Fix test
Commit migrated from https://github.com/dotnet/corefx/commit/102e4d3c731e1765a21a3a5fd3e908c428ef4a88
2018-02-14 15:52:25 -08:00
Lakshmi Priya Sekar e9414ba693 Add test infra for auth testing.
Commit migrated from https://github.com/dotnet/corefx/commit/a7d6718d2919ef81a5cebb0ce92a53b4989234d4
2018-02-14 15:52:23 -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
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
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
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
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
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
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
Paulo Janotti bfd647ca5e Disable Net.Http tests failing in Fedora.27 (dotnet/corefx#26835)
* Disable Net.Http tests failing in Fedora.27 (dotnet/corefx#26803)

* Adding comments for when tracking issue is fixed.


Commit migrated from https://github.com/dotnet/corefx/commit/e9be24d1913af98a671734267c212597fecfea70
2018-02-04 19:45:40 -08:00