Recent changes due to PR dotnet/corefx#3199 caused the `HttpResponseMessage.ReasonPhrase` property to be a null string if the HTTP server response only contained a statuscode but no description on the status line. The existing .NET Framwork behavior is to have empty string as the property value in that case.
Added a new test to validate this change.
Fixesdotnet/corefx#6721.
Commit migrated from https://github.com/dotnet/corefx/commit/19ec320403cd53ad0cba75c69a1a2c027ed867d5
We don't currently have any functional tests in the repo for using HTTP proxies. This commit adds a very simple loopback GET request proxy server, just enough to verify that HttpClient does go through the specified proxy and pass credentials if requested. If/when we get better infrastructure in place for this kind of thing, we can remove the proxy implementation and replace the test, but for now, this at least provides some automated verification cross-platform.
Commit migrated from https://github.com/dotnet/corefx/commit/db2d84b0bb4032ca21b8e7c9cfd96056ffddbab2
Correct instances of new "ArgumentException(nameof(..." so names are in the correct parameter. Where possible, I chose the resource string I felt best fit the situation. Otherwise, I created a new entry (I'm assuming there's some extra work that needs to be done there, but don't know what it is offhand).
Commit migrated from https://github.com/dotnet/corefx/commit/368fdfd86ee3a3bf1bca2a6c339ee590f3d6505d
Fixes https://github.com/dotnet/corefx/issues/5707
We are changing the .NET packages to no longer use the ‘dotnet’, ‘dotnet5.x’, and ‘dnxcore50’ monikers. This is thee first stage of the change for dotnet->netstandard.
The replacements are as follows
Old moniker | New moniker
----------------- | ------------------
dotnet5.x | netstandard1.y (where y = x -1)
DNXCore50 | netstandardapp1.5
dotnet | netstandard1.3
To prepare for this change you can do the following to your project.json. This change will require a recent build of NuGet or dotnet.exe and can be done prior to consuming the packages with the breaking change. These packages will not work with DNX.
For a project targeting dotnet5.6
```
"frameworks": {
"netstandard1.5": {
"imports": [ "dotnet5.6" ]
}
},
```
For a project targeting dnxcore50
```
"frameworks": {
"netstandardapp1.5": {
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
},
```
[tfs-changeset: 1578321]
Commit migrated from https://github.com/dotnet/corefx/commit/4435f9f2776ae007e05f4454675e56cf76a51975
WinHttpResponseStream was not tracking the amount of data read when the response used 'Content-Length' semantics. So, if the amount of bytes read from the server was less than expected, we did not return an error. This was different behavior than .NET Framework.
Fixed WinHttpResponseStream so that it will track the total number of bytes read and compare it to the expected number of bytes if using 'Content-Length' semantics. Note that we don't do this checking if the HTTP request is a HEAD request. That is because the definition of that HTTP verb is to return headers "as-if" it was returning a real response body. So, the 'Content-Length' might be set but there is no response body for a HEAD request.
For cases of using 'Transfer-Encoding: chunked' semantics for the response body, there is already error checking at the lower HTTP layer in WinHTTP.
Fixesdotnet/corefx#6231.
Commit migrated from https://github.com/dotnet/corefx/commit/7f5d6b643996306062836a17ddad643fd7e40ff2
While tracking down an issue related to exception handling in CurlHandler, I fixed up a few issues:
- On older libcurl's curl_multi_perform can return an error code that means to retry curl_multi_perform, but we were treating it as an actual error.
- Several places we were creating an HttpRequestException with a null inner exception, even if we had additional information about the cause. I've fixed those call sites to include an appropriate inner exception.
- Cleaned up a few error messages.
- Fixed one place where I was overzealous in mapping exceptions to IOException
Commit migrated from https://github.com/dotnet/corefx/commit/1faaea86f0684452a874bcd58ce259763135c6b9
As with WinHttpHandler, CurlHandler wraps exceptions in HttpRequestException. But WinHttpHandler switches to using IOException when sending exceptions out via Stream.Read/WriteAsync. This change does the same for CurlHandler.
Commit migrated from https://github.com/dotnet/corefx/commit/e39e43a3809775c41a223ffa679e4f9e693676e1
- Fix Assert that was throwing in a background thread due to mistmatched type (it was looking explicitly for HttpResponseMessage rather than any type in its inheritance hierarchy, and CurlHandler uses a derived type).
- Update project.json package versions
- Unsubscribe the listener when done with it
Commit migrated from https://github.com/dotnet/corefx/commit/9a8d97852bcce9be0b4b6b5eff5ed87f4e36119e
In particular after https://github.com/dotnet/coreclr/pull/3118, Buffer.BlockCopy has less overhead than Array.Copy when copying byte[]s, such that there's no benefit to using Array.Copy and potential benefit to using Buffer.BlockCopy.
This commit replaces usage of Array.Copy(byte[], ...) in corefx with Buffer.BlockCopy(byte[], ...). A lot of places were already using it.
(In a few places where we weren't passing lower bounds to Array.Copy with T[] arguments, I added explicit lower bounds as well to avoid the overload needing to call GetLowerBound.)
Commit migrated from https://github.com/dotnet/corefx/commit/3ab3bd6efcba669bf04d42f738fe5a495ec62940
libcurl supports four auth types (Negotiate, NTLM, Digest, and Basic), but today our CurlHandler implementation only enables three (Negotiate, Digest, and Basic), with NTLM explicitly disabled to match what was done in WinHttpHandler in corefx (the full framework enables it).
However, there are a few key differences that need to be taken into account for CurlHandler. For example, popular implementations of gssapi and Negotiate on Unix do not include implementations for fallback to NTLM. So whereas including "Negotiate" in WinHttpHandler often allows code on Windows to use NTLM if Kerberos is not available, the current state of CurlHandler often does not. And although NTLM has some known issues, if it's the only option for a scenario where a Unix front-end needs to communicate with a Windows back-end (say because the front-end doesn't have kerberos infrastructure available and the back-end only has Windows authentication enabled), we still want it to be possible for a developer to write an app that communicates with that back-end. The underlying platform supports it, the developer explicitly wants it, CurlHandler sitting in the middle shouldn't get in the way.
As such, this commit enables NTLM to be used, essentially removing the blocking of it that was previously done. However, it's not enabled by default for arbitrary credentials; rather, it's only enabled when a credential added to a CredentialCache explicitly specifies "NTLM". That way, it's available for a dev to opt-in to if desired, but just providing a NetworkCredential to CurlHandler will not use NTLM.
Commit migrated from https://github.com/dotnet/corefx/commit/6e765b2b84dcf0b6e7e3d1e0cbee6a7499a585f5
Explicit static cctors cause the C# compiler to not mark types as beforefieldinit, which in turn means that the backend compiler needs to add checks to static methods to ensure that the type has been initialized. We have a bunch of such cctors across corefx that can be easily removed; this commit does so. In a few places, it also presizes some collections to help avoid unnecessary memory pressure.
Commit migrated from https://github.com/dotnet/corefx/commit/79ae21b1b9a113230da7ebfbffa4e3c3fe36f0ac