Commit Graph
24 Commits
Author SHA1 Message Date
Stephen Toub e030befe43 Several perf improvements/tweaks for SocketsHttpHandler (dotnet/corefx#27231)
* Several perf improvements/tweaks for SocketsHttpHandler

- Chunked reads from buffer.  We now process as much of the buffer as we can synchronously during ReadAsync, rather than returning once we hit the end of a chunk.  For very small chunks that arrive quickly, this results in a huge perf increase, e.g. best case for the optimization, with lots of 1-byte chunks getting buffered together, it's now 10x faster.  With 100-byte chunks buffered together, it's 2x faster.

- Blitting byte[] to output for known headers.  Rather than using WriteStringAsync to output all header names, we now use WriteBytesAsync for known headers, with the headers precomputed into byte[]s and cached.

- Removed delegate/closure allocation from connection.  We were accidentally closing over a cancellation token, resulting in an extra delegate and closure allocation in ConnectHelper.  Also reduced the size of the EstablishSslConnectionAsync state machine by splitting the method in order to remove several arguments from being included.

- Use Utf8Formatter for hex values.  Switched from custom formatting of hex values to just use Utf8Formatter.TryFormat.

- Avoid buffering in HttpConnection.CopyToAsync(Stream).  This is used when we want to copy the whole source stream until EOF (e.g. for a Connection: close response), and thus we can skip the buffer and use the source stream's CopyToAsync directly.

- Added a test to exercise various size chunks, line endings, ReadAsync vs CopyToAsync, etc.

- Fix CopyToAsync cancellation handling.  Even though we'll abort the connection when cancellation is requested, we still need to pass the token to the destination stream's WriteAsync to give it the opportunity to cancel.  Also properly pass the buffer size through to the underlying stream's CopyToAsync where appropriate.

- Small miscellaneous cleanup, like removing a few unused arguments from methods, fixing an assert to validate the right thing, etc.

* Address PR feedback

* Fix test on netfx


Commit migrated from https://github.com/dotnet/corefx/commit/d5351fe933f0f4682ac465b656b2a438b076c24e
2018-02-20 20:54:16 -05: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
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
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 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 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
Geoff Kizer 1869a9d1a1 support LF line endings and trailer headers
Commit migrated from https://github.com/dotnet/corefx/commit/85c943fb8388585a7d49a75b879844d68962a6ab
2018-02-02 01:21:27 -08:00
Geoff Kizer a1337d4869 fix dribble tests when client disconnects on bad request (dotnet/corefx#26730)
Fixes dotnet/corefx#26729

Commit migrated from https://github.com/dotnet/corefx/commit/6f5d255a76a192906f692fd3d2b9104ab6aeb2f2
2018-02-01 06:21:36 -08:00
Geoff Kizer 6239288b27 Merge pull request dotnet/corefx#26585 from geoffkizer/httpversionhandling
clean up request and response version handling in managed handler

Commit migrated from https://github.com/dotnet/corefx/commit/2e10ed5418bac7b6b47a407b7efb28ccfcbc9f21
2018-01-31 10:19:41 -08:00
Paulo Janotti 8e297658e1 Http protocol dribble tests taking two long (dotnet/corefx#26680)
The time of inner loop is dominated by the http protocol dribble tests.

Returning the Task.Delay to Task.Yield reduces it from ~19 seconds to less than a second on a Windows 10 RS3 box.

Commit migrated from https://github.com/dotnet/corefx/commit/179cf080901f8f7f4e5499b80ad393b7370eef40
2018-01-30 16:06:51 -05:00
Geoff Kizer 5a33c6658b fix CurlHandler test for 2.0 response
Commit migrated from https://github.com/dotnet/corefx/commit/b91b6c63aa3678ba707a9900b64eea9f8e0a6d00
2018-01-29 13:31:18 -08:00
Geoff Kizer 95dd8bdc14 update tests to correctly test existing behaviors of different handlers
Commit migrated from https://github.com/dotnet/corefx/commit/380f45c16b952d5064002de0d8e936a38a49d276
2018-01-26 01:32:59 -08:00
Caesar Chen 2181b942d1 Enable some HttpProtocolTests test cases and skip them on .NET Core Windows run (dotnet/corefx#26573)
* split test cases

* disable against CurlHandler as well

* address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/e274885db32ec40b327ed4dcb3439aca41d29844
2018-01-25 15:57:38 -08:00
Geoff Kizer 79e1348226 clean up request and response version handling in managed handler, and add tests
Commit migrated from https://github.com/dotnet/corefx/commit/a1bf78551ff6de29ea02837a21620000886b2828
2018-01-24 23:17:21 -08:00
Geoff Kizer a7a639d293 Merge pull request dotnet/corefx#26511 from geoffkizer/mischttp1
Several small ManagedHandler fixes

Commit migrated from https://github.com/dotnet/corefx/commit/25c4a916bf1f35be1d009b679b19f7ebea535647
2018-01-24 21:47:48 -08:00
Caesar Chen 266628de65 Enable HttpProtocolTests test cases on .NET Core (dotnet/corefx#26525)
* split test data

* address pr feedback

* revert part of changes, and track disabled test data by new issue

* disable a Unix test case


Commit migrated from https://github.com/dotnet/corefx/commit/2836df39b74713ce26dadbd9bd3448dffbf3bf30
2018-01-23 18:56:14 -08:00
Geoff Kizer 64ed728642 make dribble test slightly more useful
Commit migrated from https://github.com/dotnet/corefx/commit/3b5eb942de8f4d2d505d5268baf0ad415bd66651
2018-01-22 12:26:17 -08:00
Geoff Kizer dfff781f66 fix issue that was causing duplicate test execution
Commit migrated from https://github.com/dotnet/corefx/commit/c512fae6eb54ffdbc6201e4a0b4491fa37a99e91
2018-01-22 12:26:16 -08:00
Stephen Toub 6d13fd5bc3 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/3b9525bd44ffab17a227cad47ae607bbf370dc1c
2017-10-18 00:19:35 -04:00
Geoff Kizer 3333dfede4 add more cases and make tests more robust
Commit migrated from https://github.com/dotnet/corefx/commit/a3cab9a48cc373eaf45a513d9c60895446c9bafc
2017-10-17 11:49:00 -04:00
Geoff Kizer cf5033763d add some basic protocol tests for status line handling
Commit migrated from https://github.com/dotnet/corefx/commit/79709c46a1e84ccae519ca58a12f9f29f0b64db5
2017-10-17 11:49:00 -04:00