Currently, if an abort occurs, it disposes of credit managers, and if there's a waiter on that credit manager, that waiter propagates an ObjectDisposedException. It should instead propagate whatever exception resulted from the abort.
Commit migrated from https://github.com/dotnet/corefx/commit/3c71b23c676c3538b33f4ae653cf6f85de77e44d
* Ensure that CancellationToken is propagated to built-in request content types
We don't currently expose the overload that would allow CancellationToken to be accessed by HttpContent-derived types in general, but we can at least ensure that when using the built-in content types, the CancellationToken provided to SendAsync is appropriately threaded through. We were doing this previously in only a few cases, where we knew that the previous overload wouldn't be overridden (namely internal types and sealed types), but we can enable the 90% scenario as well by doing a type check at run-time.
* Disable cancellation test for UAP handler
Commit migrated from https://github.com/dotnet/corefx/commit/450f49a1a80663529b31d3defafbd5e59822a16a
* Fix SocketsHttpHandler canceling request when response stream dropped
Good code using HttpClient should Dispose of the HttpResponseMessage and/or response Stream when its done with it. However, if code fails to do so, we still want to ensure that we don't leak connections/requests to the server or leak resources on the client. If the response isn't disposed but the code reads all the way to the end of it, then internally things are cleaned up. But if the response isn't disposed and hasn't read to the end, for both HTTP/1.1 and HTTP/2, we have some issues.
For HTTP/1.1, we rely on the Socket's finalization to close the associated connection. However, we use a cache of SocketAsyncEventArgs instances to handle creating connections, and it turns out that these SocketAsyncEventArgs instances are keeping around a reference to the last created Socket. If the SAEA is reused for another connection, then there's no issue, but until it is, it maintains several references to the socket: in ConnectSocket, in _currentSocket, in _multipleConnect, and then further within another SAEA instance that the _multipleConnect itself is creating for some reason. We should go through and clean all that up in SAEA, but for now, this just removes the SAEA cache.
For HTTP/2, nothing was cleaning up in this case. To handle it, we:
1. Make the response stream finalizable, such that when finalized it behaves as if Dispose were called.
2. When SendAsync completes, we remove the strong reference from the Http2Stream to the response message, such that the response (and in turn the response stream) doesn't get rooted by the Http2Connection storing the Http2Stream in its dictionary).
3. The only reason that reference was still needed was to support trailing headers. So we create a lazily-allocated list on the Http2Stream for storing trailers if any should arrive, and then when the response body completes, the response stream pulls those headers in from the temporary collection into the response that it then has a reference to. This also helps to avoid a race condition where consuming code erroneously accesses TrailingHeaders before the request has completed, in which case we previously could have been trying to write to the collection while user code was reading from it; with this change, that mutation happens as part of a call the consumer makes.
* Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/8b5eb8d9fb7857e5b40e763287f8f8832c15af31
* Retry on GOAWAY
* send correct GOAWAY on retried connection, update comment
* Harden against flakiness
* Fix: Connection refused error is different on Debian
* apply feedback
* Make partial body/received headers case deterministic, pass error code on REFUSED_STREAM
* apply latest feedback
Commit migrated from https://github.com/dotnet/corefx/commit/1841042b99062de13dc80098cede9413be569238
- Enable HTTP/1.1 and HTTP/2 to be used concurrently
- Fix duplex tests now that only custom content may be duplex
- Add option to set pooled connection lifetime to stress connection management
- Add client operation for reading portion of response and throwing the rest away
Commit migrated from https://github.com/dotnet/corefx/commit/88ab17433f45c37e4e28e2bb6dce3c74aea81c0d
* HttpStress: use randomized content lengths
Adds pseudo-random content payloads in the http stress test harness.
All random data derives from a single seed which can be optionally specified at the CLI.
* address feedback
* Remove dead code
Commit migrated from https://github.com/dotnet/corefx/commit/e642ef9c661680c3d3eb650e37fb28d82f2fafec
For 3.0:
- Adds an internal virtual AllowDuplex to HttpContent that defaults to true
- Override that on all of our HttpContent-derived types to return false
- SocketsHttpHandler's HTTP/2 implementation checks that, and if it returns false, awaits the sending of the request body as part of SendAsync.
Post-3.0, we'll revisit, likely with public surface area.
Commit migrated from https://github.com/dotnet/corefx/commit/e75dd151c9e5aa94cf33c7c9d14a53180df747dd
* Don't force flush for data packets in SocketsHttpHandler HTTP/2
Allow the write stream to request a flush via FlushAsync, but don't internally force a flush on each data packet.
* Address PR feedback
Also tweak use of ArrayBuffer.ActiveSpan/Memory.Length to just ArrayBuffer.ActiveLength.
Commit migrated from https://github.com/dotnet/corefx/commit/15abdfc3816352c64098735b79a98dd97524ee36
- "listOps" option, to see what numbers correspond to which client operations
- New client operation for HEAD
- New client operation for PUT
- New client operation for POST duplex, but that dribbles a byte at a time
- Fixed POST duplex to use ResponseHeadersRead
- Enable HTTP logging to be started to the console during a run
Commit migrated from https://github.com/dotnet/corefx/commit/2f42dde968da92f1c67a91ab7b915af7c63848e5
I'd fixed the assert message to contain the right value when MaxResponseHeadersLength was exceeded, but this error message isn't used for WinHttpHandler, and thus it doesn't contain the value. Special-case the check for just SocketsHttpHandler.
Commit migrated from https://github.com/dotnet/corefx/commit/e78b22b59d52e14d6099fd96cd713dc9d400103c