More low-hanging fruit. When building up its output, MultipartContent is already using a StringBuilder, but it's creating temporary intermediate strings which it then writes to the StringBuilder, rather than just adding the constituent pieces to the StringBuilder directly. And when computing the length of the output, it's again generating lots of intermediate strings, when it could instead just measure the size of each of the constituent pieces.
Commit migrated from https://github.com/dotnet/corefx/commit/47e9bbeab66b38b21e512243b5ed16590156d35b
When we get called back by libcurl to verify the server's certificate, we try to take a fast path where we use OpenSSL's certificate verification rather than doing our own, which is more comprehensive but also slower. However, when we added that fast path, we inadvertently ended up not setting the Channel Binding Token in that case, only doing so in the fallback path. This fixes that, moving the configuring of the CBT up to before we ask OpenSSL to verify the cert.
Commit migrated from https://github.com/dotnet/corefx/commit/bb26ba8b5375e76d00db8b371abb6e273e7b4019
This test failed once, and I expect it was just due to a network blip that caused the request to fail, but since we're not currently checking the http status code, I can't be sure. As such, I'm just adding another assert for the expected status code, and if this repros again, we'll know whether that's the issue.
Commit migrated from https://github.com/dotnet/corefx/commit/50b2ce5699eb7034a033b3d125ad62bf03b23458
Currently the shim exposes a single method to get just the information that was needed when this was written. Every time we need to get additional version info, we need to change the existing signature (which won't version well) or add additional similar signatures (will which be confusing). Instead, I've changed it to have more fine-grained entrypoints, each exposing a particular piece of info. We may end up making a few more interop calls on first-use, but the overhead is negligable.
With that scheme, I've then exposed additional entrypoints for getting version information, in order to provide better tracing and exception error messages.
This is then also used in tests to only run tests when certain features are available.
Commit migrated from https://github.com/dotnet/corefx/commit/29b0dc7b810776178bf42851064c397e47c4d0b8
We removed the lifting from the lineup so tests should reference the
latest packages in order to ensure an implementation is available.
The latest pacakges exclude implementation dependencies so I needed to
add these to projects that were depending on them coming in transitively.
Commit migrated from https://github.com/dotnet/corefx/commit/bef9061fd1238adf47b864d8924d121e4134465b
We were getting an assert if we had an authenticating proxy but didn't have any credentials to send. After the initial 407 was received from the proxy, we then tried to set credentials for a retry. But since we didn't have any, we triggered an assert in SetWinHttpCredential.
The fix is to check for null credentials after getting the 407 response. If there are no credentials, then we end the retry loop with the final 407 status code.
Commit migrated from https://github.com/dotnet/corefx/commit/89966ef37a1269471069c2ee14cdb6af51d8a707
Recent changes due to PR dotnet/corefx#3199 caused `HttpClient` on Windows to miss
`Set-Cookie` response headers when one of the header values was large
enough to cause `WinHttpQueryHeaders` to fail with
`ERROR_INSUFFICIENT_BUFFER` and advance the index.
This commit addresses the regression, by always setting the index
back to the index we want to retrieve.
Added a new test to validate this change.
Fixesdotnet/corefx#6737.
Commit migrated from https://github.com/dotnet/corefx/commit/f7e9f00aba800d2ea63e040deafcc7ee220331fc
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
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
- 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
Some fixes (adding imports, adding Platforms package) were tooled, but more complex ones (forking project.jsons, editing csproj's) were not.
Also makes dependency version validation rules case-insensitive. (I used this fix to update the versions of some packages.)
[tfs-changeset: 1573868]
Commit migrated from https://github.com/dotnet/corefx/commit/84af04317505d48feaa1e83dd5dc27ddc0f6de76