Reading from the response stream using ReadAsync() was ignoring the cancellation token passed in. To fix this, registered a delegate that will be called to dispose the WinHTTP request handle during pending I/O. This will cause the WinHTTP operation to cancel.
Added tests. For now, left them disabled to be resolved in issue dotnet/corefx#8692 next week. But wanted to get this fix in asap since it blocks partners for RTM.
Fixesdotnet/corefx#8662.
Commit migrated from https://github.com/dotnet/corefx/commit/a6e019d8e1910b9fed3c1077be23bfd9023d2837
When a server offers multiple auth schemes, WinHttpHandler is supposed
to select the more secure scheme regardless of the order of the
authentication headers. So, despite a server offering Basic and
Negotitate (in that order), Negotiate would be selected.
When using default credentials, however, it was not calling
WinHttpSetCredentials(null, null). This resulted in the first scheme
offered by the server (Basic) to be attempted. But there were no
credentials set and so a 401 resulted.
Fix WinHttpHandler so that it will always call WinHttpSetCredentials
even with default credentials. This ensures that the selected auth
scheme (in this case Negotiate) is used correctly.
Revised test configuration instructions. An IHttpModule is used for the
test server endpoint to ensure that IIS will put 'Basic' first in the
response headers.
Commit migrated from https://github.com/dotnet/corefx/commit/9c6821d9d39ebe67b03f6e491489ffbb44844612
- Add "debian.8-x64". This is the correct rid for Debian, after this
lands, I will need to update CI before we can remove "debian.8.2-x64"
- Add a generic "linux-x64" rid which we can use in cases where we want
to build for a distro where we don't yet have a set of runtime
packages. This will let us restore the managed assets (since they are
specific to "unix" or "linux" and then folks can do a native build to
get the shims and runtime and copy them over (this is a more
reasonable approach than our current strategy of just using
ubuntu.14.04-x64)
- Sort runtime sections
Commit migrated from https://github.com/dotnet/corefx/commit/6fa4bc1d215d17ff484aa3f541c5e3181f6918de
To support future security improvements, the default value for WinHttpHandler.SslProtocols will use the enum value of .None. This means that no preferred list of protocols is being expressed. And that means to use the best OS defaults. Currently this translates into using "Tls10 | Tls11 | Tls12".
This list will change over time as platforms adopt newer Tls versions and phase out older versions.
Commit migrated from https://github.com/dotnet/corefx/commit/9530ca89d99e2778d7882847230c462798e59544
It turns out that setting the WinHTTP 'Connect' timeout does nothing. We discovered this because we still got ERROR_WINHTTP_TIMEOUT errors after about 20 seconds even after setting the 'Connect' timeout to INFINITE. We discussed this with the WinHTTP team and they told us that this timeout is essentially deprecated due to performance enhancements in the TCP stack.
For the technically curious, here is the explanation. Underneath the 'Connect' timeout is really a set of TCP timeouts related to setting up the socket via the 3-leg SYN/ACK exchange. The TCP timeout is about retransmits with backoff and how many is tried by the winsock stack. The default of these initial packet exchanges is 21 seconds with 2 retransmits (3 overall SYNs) and initial RTO of 3 (3 + 6 + 12). So that explained the timeouts we saw during periods of high network congestion.
There is no API exposed in WinHTTP to control those low-level TCP timeouts. And thus it doesn't make any sense to have a 'ConnectTimeout' on the WinHttpHandler class.
Commit migrated from https://github.com/dotnet/corefx/commit/ee0b3a76c8c57ef80d1d53a16deb5b0bc6b46793
Building on the current use of environment variables for passing in test settings, added a common test helper class to allow the http and websocket tests to access alternate test servers. This will help with load balancing and network latency issues which are causing occasional timeouts in CI tests. This will also allow developers to run their own version of the Azure test endpoints. Consolidated the current environment variables used and standardized on a naming format.
Fixesdotnet/corefx#2383.
Commit migrated from https://github.com/dotnet/corefx/commit/3603ed2578220f0ecb2f101324e04acb80fa3196
* Improve WinHttpHandler logic regarding default credentials
In some cases, WinHttpHandler was not sending default credentials that were specified inside a custom ICredentials object. In other cases, default credentials would be sent even though CredentialCache.DefaultCredentials was not specified. The code was incorrectly comparing the proxy and server credential (ICredential interface) values against the DefaultCredentials object. Instead, the ICredentials.GetCredential() method should be called to compute the final NetworkCredential object. This takes into account the given uri and auth scheme.
This PR fixes the logic by delay the setting in WinHTTP for releasing default credentials. This ensures that default crdentials are released when requested.
Fixesdotnet/corefx#8176.
* Address PR feedback
Reword comments for clarity.
Add TODO issue.
Sending default creds to proxy only needs MEDIUM security policy.
Commit migrated from https://github.com/dotnet/corefx/commit/90b8ff36c8c9f9cfb1a2cf1302ff7a98ac7801ed
Previously I excluded reference assembly and package projects from
OSGroup derived properties. This is actually unnecessary, the reason
I was doing this before actually turned out to be issues with the usage
of OSGroup from builds files for pkgproj's.
Commit migrated from https://github.com/dotnet/corefx/commit/153c25729c66348f02655c031e1d4f572093cc98
Packages that support desktop need to install in projects that use
packages.config, so we should not rely on RID-specific assets for
desktop assets. Additionally, if some decides to use project.json and a
RID we need to make sure they still get the right desktop asset.
This change standardizes most of the desktop builds to specify both RID
and TFM. The common packaging targets will put the asset in both
lib/TFM and runtimes/RID/lib/TFM for desktop projects.
Commit migrated from https://github.com/dotnet/corefx/commit/0b7a2b6b4d1cf5f5a1fc2abc7e8c00c298bbe449
After further discussions and feedback regarding app-compat with legacy
servers, it's been decided we don't need to remove NTLM from the auth
type list. This commit puts NTLM back into the ordered list of auth
types. A similar change was made to CurlHandler in PR dotnet/corefx#7923.
Due to current limitations with the Azure test server endpoints
regarding integrated auth, this change was tested manually.
Commit migrated from https://github.com/dotnet/corefx/commit/583509a435891630162102ae4f57942f0e583123
WinHttpHandler often creates an exception in response to some native error code and then stores that exception into a Task. As the exception isn't actually thrown until it's propagated out at the eventual await site, the these exceptions often lack a good stack trace to help highlight where the error came from.
This commit ensures that such exceptions have a stack trace by throwing and catching them before storing them into either another exception as an inner exception or directly into a Task. I've not touched cases where the exception was already being thrown or where an exception was wrapping another exception that has a stack trace.
Commit migrated from https://github.com/dotnet/corefx/commit/31bd97c86fd90faeb977d67c495198dbb2a96000
*
In WCF repo many of our test projects are more than one level below the 'tests' directory.
*
If this doesn't break anything in corefx could we take this change?
* Amending to remove corefx\src\System.Net.Sockets\tests\PerformanceTests\System.Net.Sockets.Async.Performance.Tests.builds
* Amending again with more test .builds files that needed to be removed.
Commit migrated from https://github.com/dotnet/corefx/commit/8cac0d4afab96e15837818ca1abfbd9068008458
To support important customer scenarios for CoreFx RTM, we will be updating the System.Net.Http contract from 4.0 to 4.1. We are focusing on HttpClientHandler enhancements.
We will be submitting the final proposed list of additions as part of issue dotnet/corefx#7623. As part of updating the contract to 4.1, we are also OOB'ing the Desktop (net46 Windows) implementation so that the package won't be a facade over Desktop but rather a full implementation. This is possible since System.Net.Http has always been a standalone dll in the .NET Framework. As part of this, we are changing the implementation for Desktop from the legacy HttpWebRequest sockets stack to the WinHttpHandler stack based on native WinHTTP. This will give us a good path forward as WinHttpHandler stack will be getting HTTP/2.0 support with newer versions of Windows 10.
This initial PR has a few API additions that we are definitely going to be adding. It's important to get these changes into the builds so that we can fully bake the OOB Http.dll assembly on all the platforms and continue package testing.
There is an existing System.Net.Http.WebRequestHandler class in the .NET Framework located in System.Net.Http.WebRequest.dll. This class is a subclass of HttpClientHandler. Due to this, we are being careful not to cause collisions with some of these added properties. WebRequestHandler has a 'ClientCertificates' property and a 'ServerCertificateValidationCallback' property. So, we are aligning/renaming the properties as we add them to HttpClientHandler OOB assembly. This may get altered slightly as we finalize the 4.1 System.Net.Http API.
Commit migrated from https://github.com/dotnet/corefx/commit/97c940eec1f6afe3e4af31e72d79c3a11e7b1ff1
This change uses some features available in an updated version of
buildtools. Instead of resolving the test-runtime for each of our test
projects as a separate step, we will now add a "reference" to it from the
project.json of each test project. This will allow us to resolve the nuget
assets from both it and the test project at the same time. This will be
more robust than our current process, which is very fragile and
error-prone.
The above is made possible by an updated version of
"PrereleaseResolveNuGetPackageAssets", which is the buildtools task
responsible for resolving test assets from nuget packages. This task also
has a lot of additional validation, which triggers a lot of warnings in
corefx. I've made various changes to csproj's and to project.json's around
the repository in order to satisfy those warnings.
Commit migrated from https://github.com/dotnet/corefx/commit/622ee8f512497fc07621de15e41c6bd575f387c9