To behave similarly to netfx and WinHTTP, which ensure some known methods are sent uppercased. They differ on exactly which, so I've standardized on doing the ones for which HttpMethod has static properties. Since we're paying for this normalization, I've then taken advantage of it to use reference comparisons on the HttpMethod instances where we're later checking for known methods, and I also removed an allocation from HttpMethod's GetHashCode, since we're now storing these in a dictionary which uses GetHashCode.
Commit migrated from https://github.com/dotnet/corefx/commit/02b11fae98fd2d6662e1c490cae8462b0ce1ecdf
Many dozen of Http tests are failing on UAP test runs. This is not showing up during PR/CI
because the UWP leg only is building the product and test sources and not actually running
any tests. However, the test failures show up in Helix and also when run locally on a dev machine.
So, for now, I'm disabling some of these tests so that the inner and outer test runs will pass.
Contributes to dotnet/corefx#29802Closesdotnet/corefx#27953
Commit migrated from https://github.com/dotnet/corefx/commit/3326f3f24dd083f0966c8f71c7d1e8c2caa1ddae
- Add “Connection: close\r\n” response header in more cases where the loopback server explicitly closes a connection, and in particular where the client makes multiple connections.
- Change several Task.WaitAlls on paired tasks to instead use our WhenAllOrAnyFailed helper.
Commit migrated from https://github.com/dotnet/corefx/commit/cebcf436358600a4808656b142a74f57d1e8f6f0
* 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
* 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
- 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