Commit Graph
1592 Commits
Author SHA1 Message Date
Stephen Toub 4c75f5d1cd Add response drain max time to SocketsHttpHandler (dotnet/corefx#27708)
* Add response drain max time to SocketsHttpHandler

Adds support for a max time limit on how long we'll try to drain a connection before returning it to the pool, and adds a (currently non-public) knob for controlling that limit.

This also fixes a race condition with regards to cancellation and chunked responses.  If cancellation was requested after returning the connection to the pool but before we disposed of the cancellation registration, someone else could get the pooled connection and then cancellation of one request could end up canceling the other request.

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/4ca662cf7ed1bff8e423839936083838d705008d
2018-03-06 07:38:06 -05:00
Geoff Kizer d02b3a1091 Merge pull request dotnet/corefx#27748 from geoffkizer/testplatformfixes
fix some conditional test logic related to SocketsHttpHandler

Commit migrated from https://github.com/dotnet/corefx/commit/0ad6968adb463fa1470ba4af09f270311c8a25a3
2018-03-05 19:31:46 -08:00
Geoff Kizer 2d0c60393b Merge pull request dotnet/corefx#27739 from geoffkizer/cachehostheader
SocketsHttpHandler: Change caching of Host header value to include port when necessary

Commit migrated from https://github.com/dotnet/corefx/commit/7c70d7a3608b528805ce5a71893ce9ac497f88a4
2018-03-05 17:59:36 -08:00
Geoff Kizer e83463359d fix some conditional test logic to ensure we're not disabling SocketsHttpHandler tests
Commit migrated from https://github.com/dotnet/corefx/commit/c2db57418b02cb03c2f27a38567d86436746a275
2018-03-05 14:22:55 -08:00
Geoff Kizer 4fb8e75bc9 address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/2c3f9b264a837d4d7ccd767af6210268d406a07e
2018-03-05 12:51:32 -08:00
Stephen Toub 38cfd8b969 Add folded response header support to SocketsHttpHandler (dotnet/corefx#27727)
* Add folded response header support to SocketsHttpHandler

The feature is deprecated by RFC 7230, but some servers still utilize it, and if they do, SocketsHttpHandler currently fails (WinHttpHandler and the netfx handler both allow it, CurlHandler currently fails as well).  This commit updates the header parsing logic to allow for them.

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/dc355e96d61d98dee48a809571edda3c1c7e5525
2018-03-05 15:32:52 -05:00
Geoff Kizer 10238291c6 change caching of Host header value to include port when necessary
Commit migrated from https://github.com/dotnet/corefx/commit/5c49c76471798db2dbb14c245d0c24129570b835
2018-03-05 11:29:43 -08:00
Stephen Toub 7482b6a4b0 Expose and roll out ValueTask extensibility
This commit does several things:
- Exposes the new `ValueTask` extensibility model being added in coreclr.  The ValueTask-related files will separately be mirrored over to corefx to enable the netstandard build of System.Threading.Tasks.Extensions.
- Adapts all `Stream`-derived types to return `ValueTask` instead of `Task` from `WriteAsync`.
- Changes the new `WebSocket` `SendAsync` method to return `ValueTask` instead of `Task`, and updates the `ManagedWebSocket` implementation accordingly.  Most `SendAsync`s on `ManagedWebSocket` should now return a `ValueTask` that's either completed synchronously (no allocation) or using a pooled object.  It now uses the underlying transport's new `WriteAsync` overload that returns `ValueTask`.
- Switches more uses of `ReadAsync` and `WriteAsync` over to the new overloads, including in Process, DeflateStream, BrotliStream, File, HttpClient, SslStream, WebClient, BufferedStream, CryptoStream,
- Removed some unnecessary array clearing from various routines using ArrayPool (after the clearing was added we changed our minds and decided clearing was only necessary in very specific circumstances)
- Implements a custom `IValueTaskSource` in Socket, such that async receives and sends become allocation-free (ammortized).  `NetworkStream` then inherits this functionality, such that its new `ReadAsync` and `WriteAsync` are also allocation-free (in the unbounded channel implementations; we can subsequently add it in for bounded).
- Implements a custom `IValueTaskSource` in System.Threading.Channels, such that reading and writing are ammortized allocation-free up to one concurrent reader and writer.
- A few random things I noticed as I was going through, e.g. missing ConfigureAwait, some incorrect synchronization in tests, etc.
- Adds a ton of new tests, mainly in System.Threading.Tasks.Extensions, System.Threading.Channels, and System.Net.Sockets.


Commit migrated from https://github.com/dotnet/corefx/commit/6d1671b2cfcf130b7bc6c059bb0508073426532a
2018-03-02 09:56:25 -08:00
Simon Nattress 0aa965eb67 Re-enable UAP builds (dotnet/corefx#27531)
* Build uapaot System.Numerics.Vectors

With `Vector<T>` now residing in System.Private.CoreLib, directly reference System.Private.Corelib instead of contracts just like netcoreapp does.

Add uapaot flavor since System.Private.CoreLib has a different strong name key on that platform.

* Make EnsureExtendedPrefixOverMaxPath available to UAP

Add the helper method `System.IO.PathInternal.EnsureExtendedPrefixOverMaxPath` to Common\src\System\IO\PathInternal.Windows.cs. It was previously not visible to UAP since  Common\src\CoreLib\System\IO\PathInternal.Windows.cs is not included in UAP compilation.

* Keep SocketsHttpHandler out of UAP builds

SocketsHttpHandler is not supported in uap and is currently leaking into UAP builds since they've been disabled for a few weeks. Adjust the contract so it's not available to UAP, and clean the implementation assembly so SocketsHttpHandler internals don't leak out into HttpClientHandler.Core.cs.

* Fix GetAddrInfoExSupportsOverlapped UAP build break

`System.Net.NameResolutionPal.GetAddrInfoExSupportsOverlapped` uses LoadLibraryExW which is not compatible with UAP (which only supports LoadLibrary of DLLs within a container). Refactor the helper so UAP returns false.

* Revert "Disable UAP legs per dotnet/corefx#26802 (dotnet/corefx#26822)"

This reverts commit dotnet/corefx@120dce456a.

* Revert "Disable UAP configurations in all configurations build"

This reverts commit dotnet/corefx@2202b4fd49.

* Revert "Disable UAP official builds (dotnet/corefx#26871)"

This reverts commit dotnet/corefx@ef79caf14c.

- Baseline the ApiCompat and GenFacades failures in System.Runtime.Extensions and System.Threading.ThreadPool.
- Adjust naming of files to match branch conventions
- Fix up some configuration issues with uap packaging. The CoreFX.Private.TestUtilities packaging needs updated build tools which can map between uwp6.0 and netstandard2.0.
- ifdef out Thread.GetCurrentProcessorId until we get a new System.Private.CoreLib.


Commit migrated from https://github.com/dotnet/corefx/commit/c9cdfba45e62eeac28ef554d8bbdfdd620a0fd15
2018-03-01 17:59:35 -08:00
Geoff Kizer e16aef7038 Merge pull request dotnet/corefx#27551 from geoffkizer/ntlm
SocketsHttpHandler: add ntlm auth and proxy auth for tunnel, and rework auth handling generally

Commit migrated from https://github.com/dotnet/corefx/commit/8ce711e455f33f7a4bcb9cdb0c5374984e11035e
2018-03-01 11:22:24 -08:00
Geoff Kizer c2e259c898 disable proxy test for WinHttpHandler on Win7
Commit migrated from https://github.com/dotnet/corefx/commit/3a361591e034962cf2ce34d374beefc04bd83c72
2018-03-01 09:48:55 -08:00
Geoff Kizer 6ab46589a9 revert preauthenticate change
Commit migrated from https://github.com/dotnet/corefx/commit/1810ecb8564830d72a8b8b7404d5cf846e1a6ccb
2018-02-28 23:19:49 -08:00
Geoff Kizer b948297e59 fix netfx test build
Commit migrated from https://github.com/dotnet/corefx/commit/271326fe70b08119b1463128db1e43c73a1fbad3
2018-02-28 13:22:42 -08:00
Geoff Kizer d0927416fb address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/138dd3fe3d7c65feb22ea7df86e29715ada2a9d9
2018-02-28 13:17:13 -08:00
Geoff Kizer b8171acbe7 update arguments passed to NTAuthentication constructor
Commit migrated from https://github.com/dotnet/corefx/commit/e2f96c8f026776655483a1ac4d46cba11bc4204a
2018-02-28 12:17:02 -08:00
Geoff Kizer e59a5d3bb0 fix trace conflict issue
Commit migrated from https://github.com/dotnet/corefx/commit/0288644ee8b16e54a9d6bd1fad8b8a50a24bf6d0
2018-02-28 11:42:23 -08:00
Geoff Kizer 8b0d6d1de0 fix linux build
Commit migrated from https://github.com/dotnet/corefx/commit/98ef3cf0e37f376a0378d4ad061ec68fbec2e829
2018-02-28 11:22:46 -08:00
Geoff Kizer f88c886479 Merge pull request dotnet/corefx#27536 from geoffkizer/curldrainfix
disable drain test variation for CurlHandler

Commit migrated from https://github.com/dotnet/corefx/commit/e3ecae6e2ae38425d6a98e86d3f9f3be378661a6
2018-02-28 03:11:25 -08:00
Geoff Kizer ec56dd2753 Merge pull request dotnet/corefx#27545 from stephentoub/exposedrainsize
Expose SocketsHttpHandler.MaxResponseDrainSize

Commit migrated from https://github.com/dotnet/corefx/commit/32e4f8e9b8fd1421e199166bf41a37f21a646fac
2018-02-28 03:05:11 -08:00
Geoff Kizer 64ea71c544 add ntlm auth and proxy auth for tunnel, and rework auth handling generally
Commit migrated from https://github.com/dotnet/corefx/commit/5d209e6e6280ced6c3ef4afda57c6f486ae36118
2018-02-28 02:57:05 -08:00
Geoff Kizer c92b7d0e1c disable Expect: 100-continue test on WinHttpHandler (dotnet/corefx#27538)
Commit migrated from https://github.com/dotnet/corefx/commit/c0cf481d1ca8532745124ffde3b16f6ea19639b0
2018-02-28 01:42:19 -05:00
Stephen Toub 25fcf57620 Expose SocketsHttpHandler.MaxResponseDrainSize
Commit migrated from https://github.com/dotnet/corefx/commit/900f9aabac877ec67efb13fbe8af8e07f71dcd95
2018-02-28 01:39:08 -05:00
Geoff Kizer a945f1b324 disable drain test variation for CurlHandler
Commit migrated from https://github.com/dotnet/corefx/commit/05e3ec4e001a1754facfd44ac78c6aa33b5fe86a
2018-02-27 19:06:38 -08:00
Stephen Toub 49571aef5e Add MaxResponseDrainSize, and fix a few draining bugs (dotnet/corefx#27476)
* Add MaxResponseDrainSize, and fix a few draining bugs

I've added MaxResponseDrainSize to make the setting configurable rather than a const; I left it internal until the API is approved.

In adding tests for it, I found a few existing bugs in draining that I fixed:
- HttpConnectionResponseContent nulls out its Stream when the Stream is consumed.  Then when the response content is disposed, the Stream is null, so it's not disposed, so it's not drained.
- HttpContentReadStream's Dispose wasn't checking whether it was already called, and would kick off a new draining operation if the connection was still associated.  So if the stream was disposed multiple times, which happens if the response content and stream are both disposed (since the content disposes of the stream), we end up corrupting the response due to multiple threads concurrently accessing and draining it.

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/eb80d133d066e72626643dddb3171bf9bb6a7c42
2018-02-27 08:35:03 -05:00
Geoff Kizer fe3585d9c5 Merge pull request dotnet/corefx#27220 from wfurt/ssl_Proxy2
support for CONNECT method in SocketHttpHandler 

Commit migrated from https://github.com/dotnet/corefx/commit/8e88850940605ef7d57cfc7b570bdf9bf2b8d822
2018-02-24 22:20:16 -08:00
Geoff Kizer 10fb7486c6 add issue number
Commit migrated from https://github.com/dotnet/corefx/commit/cc8db63f8688043306088b0057b05f69aa23e921
2018-02-24 14:52:34 -08:00
Geoff Kizer 9dba5b8340 revert change to existing redirect test and split into new test, disabled for WinHttpHandler
Commit migrated from https://github.com/dotnet/corefx/commit/edfa136cb9b003ac5575f9d1ad3e11dfbc147d76
2018-02-24 14:30:04 -08:00
Tomas Weinfurt c43d267d92 be more liberal on what exception type to get on handshake failure (dotnet/corefx#27352)
* be more liberal on what exception type to get on handshake failure
* refactor test code to address feedback from review
* move "catch XX" to separate line


Commit migrated from https://github.com/dotnet/corefx/commit/517238c264741d99a28c60178da9d65bac3d3fe5
2018-02-23 10:20:28 -08:00
Tomas Weinfurt 73922f6a6f update AllowAllCertificates so it works on systems with curl/nss. Disable test on Windows as it seems to cause some troubles.
Commit migrated from https://github.com/dotnet/corefx/commit/85756b823938ca5c5f6583d024a14363ad266f7d
2018-02-23 10:13:47 -08:00
Geoff Kizer b177f8471b fix race in SSL cancellation logic and move to ConnectHelper (dotnet/corefx#27397)
Commit migrated from https://github.com/dotnet/corefx/commit/2d05b2fdebddeb1749119afbe9605f26b54cd15b
2018-02-23 08:40:33 -05:00
Stephen Toub bd4c7bfebb Increase timeout in Expect100ContinueTimeout_SetAfterUse_Throws test
A few outerloop runs just missed the old timeout, presumably due to being overloaded.

Commit migrated from https://github.com/dotnet/corefx/commit/603c69d8ef82fa5517ec68b5a84fe3dd897fda0f
2018-02-23 08:10:48 -05:00
Tomas Weinfurt 96d06a74f6 refactor Proxy_UseSecureProxyTunnel_Success little bit.
Commit migrated from https://github.com/dotnet/corefx/commit/9fa2b9ab41d361cb1e683a95585abd91f147c67b
2018-02-22 20:37:04 -08:00
Geoff Kizer 8df3174c2f Merge pull request dotnet/corefx#27377 from geoffkizer/redirecttestfix
add shutdown call to try to make redirect test more reliable

Commit migrated from https://github.com/dotnet/corefx/commit/59481ca56906713ef9e5e4890388f4cd2fe9c699
2018-02-22 15:57:26 -08:00
Tomas Weinfurt 3a42fc41f9 Merge branch 'master' of https://github.com/dotnet/corefx into ssl_Proxy2
Commit migrated from https://github.com/dotnet/corefx/commit/f909b9f95f099a197e7bb04479b930f0e596dfb7
2018-02-22 15:36:16 -08:00
Geoff Kizer 286740559c add shutdown call to try to make redirect test more reliable
Commit migrated from https://github.com/dotnet/corefx/commit/11a9368d1b1fbf0eca11406473e1e7f0c712ff3c
2018-02-22 12:03:09 -08:00
Stephen Toub 0365092b59 Disable SocketsHttpHandler's concurrent content sends (dotnet/corefx#27341)
* Disable SocketsHttpHandler's concurrent content sends

SocketsHttpHandler currently has some support for allowing request content sending to run concurrently with response content receiving.  However, we don't actually have a need for this, and there are a lot of subtleties that would need to be made robust, e.g. how to handle exceptions that occur concurrently in the sending and receiving.  For now, we're removing it.  Unless ExpectContinue is set to true, we just send the content before receiving the response, and if it is set, we start the send and then wait for it once we've received the final status code from the server.

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/fecb772f0607dc85afdb782eda1b42ddffcba61b
2018-02-22 14:58:19 -05:00
Stephen Toub 3c9dd1b90a Fix fragment handling in HttpClient (dotnet/corefx#27360)
* Fix fragment handling in HttpClient

SocketsHttpHandler isn't sending fragments, nor is it properly inheriting the fragment from the original request URI into the redirect location URI when the original URI had one and the redirect URI did not, even though RFC 7231 says it must.  This commit fixes that for SocketsHttpHandler.

WinHttpHandler also isn't handling this inheritance according to the RFC. It appears that the logic for WinHttpHandler would actually need to be changed in WINHTTP itself, or else WinHttpHandler would need to be changed to do the redirects itself.

Neither CurlHandler or NetFxHandler send fragments at all.

This commit also fixes the test to correctly compare the expected and actual Uris... apparently Uri equality doesn't factor in fragments, so they're first converted to strings.  It also updates the test to also validate that the server received the URI with the fragment included.

* Disable the fragments test on WinHttpHandler

Apparently it sometimes doesn't do the "right thing" even in other cases.


Commit migrated from https://github.com/dotnet/corefx/commit/a273be657f6666e333fd902965a56046d6f48018
2018-02-22 14:25:05 -05:00
Geoff Kizer ebf914566e Merge pull request dotnet/corefx#27315 from geoffkizer/responsedrain
SocketsHttpHandler: add response stream drain

Commit migrated from https://github.com/dotnet/corefx/commit/662d9bffae0c1e6119d1a62b073966d8aee673d3
2018-02-22 09:36:37 -08:00
Geoff Kizer d803a21ca8 add logging for drain, and update tests to reflect higher limit for managed handler
Commit migrated from https://github.com/dotnet/corefx/commit/0070410383dfc528f394f3b73787aa9e575afc62
2018-02-21 15:47:40 -08:00
Geoff Kizer 00c926a26f rework content length logic to drain buffer before doing length check
Commit migrated from https://github.com/dotnet/corefx/commit/3584bdbfd21c0f4b02bffe1170febb2e6fa9c0ad
2018-02-21 14:38:05 -08:00
Geoff Kizer 6bd49e65b9 Merge pull request dotnet/corefx#27266 from geoffkizer/authrefactor
SocketsHttpHandler: split auth and redirect handling back into two separate handlers

Commit migrated from https://github.com/dotnet/corefx/commit/d8d32ab5abbec82f4f1346f64e51e525508c6f39
2018-02-21 14:20:13 -08:00
Geoff Kizer f8d6e9d663 address review feedback
Commit migrated from https://github.com/dotnet/corefx/commit/5c622083a4a2228b2b490929da6d94b97c6f6e33
2018-02-21 10:51:28 -08:00
Geoff Kizer 6bdeebdc0c add response stream drain
Commit migrated from https://github.com/dotnet/corefx/commit/3abd27db07e592629b53bbaca26dd9c8c4411ff1
2018-02-20 21:25:11 -08:00
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 eac46c0cce Expose SocketsHttpHandler.ConnectTimeout/Expect100ContinueTimeout (dotnet/corefx#27292)
Commit migrated from https://github.com/dotnet/corefx/commit/3b2d39593672a7f49946e453a42cfae62f2ac88f
2018-02-20 18:30:34 -05:00
Geoff Kizer c3645e3634 reconcile merge and fix curl issue
Commit migrated from https://github.com/dotnet/corefx/commit/4a779f45ac9475925a967a0b9ce3f9bd277fd041
2018-02-20 15:28:05 -08:00
Geoff Kizer cde1aa194a address review feedback and fix issue with redirect to GET handling
Commit migrated from https://github.com/dotnet/corefx/commit/37baaf29aabfd4bea4e1912b5a672a8c7af79c20
2018-02-20 15:28:05 -08:00
Geoff Kizer 54e5345381 split auth and redirect handling back into two separate handlers
Commit migrated from https://github.com/dotnet/corefx/commit/e8a17715fba4ba6cfce4043a2cd117474dfcee05
2018-02-20 15:28:04 -08:00
Max Kerr 5953018eb9 Log when an insecure Https -> Http redirect is blocked (dotnet/corefx#27077)
.NET Core does not allow insecure redirects from https to http, but .NET Framework does. Developers have had some trouble diagnosing the issue when they run into this difference. This change adds logging to help developers track down what is going on.

Commit migrated from https://github.com/dotnet/corefx/commit/1fd7d79fc36ca113bdabbee4204e15ae5bcde24a
2018-02-20 14:31:16 -08:00
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