SocketsHttpHandler doesn't own the proxy its given; the lifetime of that proxy is up to the developer supplying it. We may also end up using a global proxy instance if the developer hasn't explicitly supplied one. However, SocketsHttpHandler's internal HttpConnectionPoolManager was disposing of this proxy instance on its disposal. For proxies that implement IDisposable, as our global default proxy does, that can be very problematic; on Windows, our default proxy has a SafeHandle, and once its disposed, every subsequent request to the proxy will fail (an exception gets thrown and then internally eaten). The fix is simply to stop disposing a proxy instance we don't own.
While investigating this, I also made a few style tweaks to WinInetProxyHelper, removing private property setters, so as to better be able to see that certain values were readonly and never changed after construction.
Commit migrated from https://github.com/dotnet/corefx/commit/c6a849b8d24fc48bb0bbdb9f9165752a4a19459b
* Making Exceptions serializable
* Remove EventLog serialization exceptions from tests since they won't work on non-Windows platforms
* Fix build and add internal exceptions as well
* Add parameter-less constructor to RethrowException
* Adding PR Feedback
* Fix allConfigurations build
Commit migrated from https://github.com/dotnet/corefx/commit/7075587321a1b6b59248b1a6c7ea04fc803eab96
- Fix/adjust several uses of string interpolation in SocketsHttpHandler.
- Remove a Task.WhenAny allocation from SendAsync in the common case where there is no request content or where the request content sending completes synchronously.
- In GetWaiterTask use CT.UnsafeRegister instead of Register, as ExecutionContext, as the callback doesn't need context flowed.
- In GetWaiterTask, avoid allocating an unnecessary Task for the _waitSource if the token isn't cancelable.
- In GetWaiter task's cancellation callback, avoid allocating an OCE not associated with the wait. Instead, just complete the waiter, and then rely on the subsequent cancellation check to propagate cancellation appropriately.
- Use CompareExchange to write to _abortException so that _abortException never changes its value once it's non-null. We currently have several code paths that check the type of _abortException and then do something based on it, and that could cause issues if its type could change between the check and the action.
- Clean up HTTP2 SendAsync method, e.g. remove unnecessary tmps, remove duplicated await, use slightly more descriptive variable names, only wrap OCE with one for cancellationToken if cancellationToken has had cancellation requested.
- Replace a use of ExceptionDispatchInfo.Throw with just throw. The former should be used when and only when throwing an exception object that may previously have been thrown; in this case we're throwing a new object that was never thrown before.
- Add detailed comment describing thread-safety around Http2Stream._waitSource
- Clean up a few comments
- Add some missing .ConfigureAwait(false) in loopback servers
Commit migrated from https://github.com/dotnet/corefx/commit/e771af6f93fe4bdc9e6172563e42422d5fdd30ff
* follow up on duplex operation
* updates
* add test for cancelation
* log responseHeadersTask if bodyTask fails first
* improve cancelation
* feedback from review
* update SendAsync_ConcurentSendReceive_Fail test
* feedback from review
* update SendSettingsAckAsync
* more HTTP/2 cancelation tests
* update test to accept any derivative from OperationCanceledException
* feedback from review
* roll-back changes in AcceptConnectionAsync
Commit migrated from https://github.com/dotnet/corefx/commit/cad5159981f518f455be3528d0ee8eca2e00742a
This adapts the existing HttpClientMiniStress tests to run with HTTP/2 as well as HTTP/1.1. Some caveats, though:
- All of these existing tests spin up a new server per request, so they're not stressing arguably the most important aspect of the client's HTTP/2 implementation, that of sharing the single connection across all requests. Our loopback server is not currently robust enough to handle concurrent requests; we should look at switching over to using Kestrel.
- The tests run really slowly, ~40x slower than for HTTP/1.1. However, the HTTP/1.1 tests are non-SSL, these are of course SSL, and it looks like that's actually the difference. In particular, something about how our test server gets its test certificate appears to be taking the vast majority of the time. (We should separately see if we could tweak that, not just for this purpose, but more so to help speed up the whole suite.)
Commit migrated from https://github.com/dotnet/corefx/commit/a7c893ab3d3e50b11c7fa2338882c8964e0a290d
* Factor out repo restore into seperate props/targets
* Use configuration system msbuild sdk
* Remove XUnit.Runtime.depproj
* Remove TargetGroup usages in test projects
* Fix ILLink configuration
The ILLink package contains netcoreapp2.0 assets which are compatible
with netstandard2.0. Removing the old TargetFramework to restore
successfully.
* Remove usages from TargetGroup in Directory.Build.props
* Remove dead net4* configurations
* Change tests.builds to tests.proj sdk proj
* Make externals dir proj an sdk project
* Consume Microsoft.DotNet.CoreFxTesting as an msbuild sdk
* Use runtimeconfig.template.json
* Remove SupplementalTestData
* Map shared framework version to product version
* Stop binplacing tests
* Move some tool depprojs to targets during restore
* Remove dead code
* Use PackageReference instead of RefFromRuntime in test
* Disable using an apphost
* Copy compression testdata manually cause unicode bug
* Remove target batching in optimizationData
* Reference packaging tools from CoreFx.Private.TestUtilities
Commit migrated from https://github.com/dotnet/corefx/commit/c4c1985531cc1f25c805bbc4801b85c98e0dfee0
* HPACK correctness tests/updates. Resolvesdotnet/corefx#31316.
Fixes:
- Fix check allowing out-of-bounds write in IntegerEncoder when an integer requires more than one byte and there is not enough buffer space.
- Encode Content-Type with a "Literal Header Without Indexing -- Indexed Name" rather than with a literal name.
Updates: (ported from ASP.NET HPACK code)
- Dynamic table size update must be the first instruction in the header block. Throw an exception when not the case.
- Throw an exception when we've reached the end of header data and we are still mid-parse.
New:
- Asserts, documentation, and tests for IntegerEncoder and IntegerDecoder.
- Tests to verify HttpClient is correctly encoding the different variants of headers.
- HPackDecoder tests (ported from ASP.NET)
* Address review feedback and fix CI.
* Address review feedback.
* Fix licensing to use ASP.NET's licensing. Add a TPN.
Commit migrated from https://github.com/dotnet/corefx/commit/ed526597f3f0d4653588ba0129fcaf18e2e5a4ef
* Change EstablishConnectionAndProcessOneRequestAsync test method to use WhenAllOrAnyFailed
CI is currently hanging when the client operation fails in a way that the server never hears about the request, and waits forever.
* Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/0b5479dde70fc565c5edefac4259578865496e84
The GoAwayFrame_AbortAllPendingStreams_StreamFailWithExpectedException test has been frequently hanging on some Linux distros. This adds some diagnostics to help track it down in CI: every minute, it'll dump out the fields of the async state machine, which if nothing else will let us see which await it's stuck on and what is the state of each of the tasks.
Commit migrated from https://github.com/dotnet/corefx/commit/410a162f68eb319e8066ac7bf2d7bcd6e2ce47d0
There are logic errors in ConnectHelper's catch blocks regarding cancellation. It's catching all exceptions and then trying to decide whether it should wrap the exception in an OperationCanceledException (based on whether cancellation was requested), but it's ignoring the possibility that the exception already is an OperationCanceledException.
Commit migrated from https://github.com/dotnet/corefx/commit/80252bbc5cf2f933aef1f30d6bec7deaa3064f54
* expect100
* updates
* remove dead code
* fix tests
* use configured value for allowExpect100ToContinue timer
* feedback from review
* dispose expect100Timer
* feedback from review
* feedback from review
* feedback from review
* small updates to sync up with master changes
* add concurent send/recive and more tests
* fix netfx
* feedback from review
* feedback from review
* feedback from review
* feedback from review
* feedback from review
* kick ci
Commit migrated from https://github.com/dotnet/corefx/commit/b4fa2006c2e9757e4446e3fdad413bdbf265eedc
CancellationToken.Register captures the current ExecutionContext and uses it to invoke the callback if/when it's invoked. That's generally desirable and is the right default, but in cases where we know for certain the callback doesn't care about EC (e.g. we're not invoking any 3rd-party code), we can use UnsafeRegister instead (newly added in 3.0), which skips capturing the ExecutionContext, as if Capture returned null. This helps few a couple of small costs:
- Avoids thread local lookups to capture the current EC.
- Avoids additional delegate invocations and thread local gets/sets to invoke the callback with the captured EC.
- Avoids holding on to the EC in case it's needed, which can potentially keep alive an unbounded amount of state due to AsyncLocals.
Commit migrated from https://github.com/dotnet/corefx/commit/b1a1bfa0997ce35e8540fbbe74276858e315807e