Commit Graph
190 Commits
Author SHA1 Message Date
stephentoub bf66904b51 Add CurlHandler.MaxConnectionsPerServer option
Adds MaxConnectionsPerServer to CurlHandler.


Commit migrated from https://github.com/dotnet/corefx/commit/cf89034e4425fcd5bc4d00819e29c8c06a47d954
2016-04-04 22:18:07 -04:00
Stephen Toub 8f452c4b3c Merge pull request dotnet/corefx#7502 from dotnet-bot/UpdateDependencies20160404102117
Updating CoreFX dependencies to rc3-24004-00

Commit migrated from https://github.com/dotnet/corefx/commit/a2443bcbe3aa410007c1f1fc4f2c4394e5ce189e
2016-04-04 21:56:26 -04:00
Stephen Toub 44b8eb2705 Merge pull request dotnet/corefx#7462 from stephentoub/curl_contentlength
Fix CurlHandler Content-Length handling on redirects

Commit migrated from https://github.com/dotnet/corefx/commit/8992e73cf1bf09f93cd65ed2b0598c2508afa9e1
2016-04-04 20:23:12 -04:00
dotnet-bot 9f65b1e1ef Updating CoreFX dependencies to rc3-24004-00
Commit migrated from https://github.com/dotnet/corefx/commit/9fd2c8863f2be58ee5d1431f0c658de61e991551
2016-04-04 20:19:10 -04:00
Stephen Toub 4b74e9a08a Merge pull request dotnet/corefx#7503 from stephentoub/curlhandler_defaultproxycredentials
Add CurlHandler.DefaultProxyCredentials

Commit migrated from https://github.com/dotnet/corefx/commit/4bd8d0fcacce9a49a44c9b32022e892c109c7e15
2016-04-04 20:08:20 -04:00
stephentoub 15145110b1 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/d6ec5160a2112fcc0b28ceecc89b678c28b66ff8
2016-04-04 19:06:36 -04:00
stephentoub f44dff3e55 Fix CurlHandler Content-Length handling
CurlHandler was explicitly setting the Content-Length header, which overrides libcurl's default handling of Content-Length.  This means that  Content-Length was being sent even when it shouldn't have been, such as when redirecting a POST to a GET.  This commit changes how we handle Content-Length.  Rather than explicitly setting the header ourselves, we let libcurl do it, and we tell it the length of the input via the INFILESIZE and POSTFIELDSIZE options.

A few other issues addressed as well in the act of fixing this:
- A SafeHandle wasn't being disposed of in the case of a redirect.
- 301 wasn't being considered a redirect status code for the purposes of credential handling.
- Some code could have been a bit cleaner.


Commit migrated from https://github.com/dotnet/corefx/commit/864f0926754fbb781b81b543f972e069f6295a0c
2016-04-04 19:06:33 -04:00
stephentoub 15ccbd065a Add CurlHandler.ConnectTimeout
Adds a timeout to the connection phase of CurlHandler.


Commit migrated from https://github.com/dotnet/corefx/commit/6880dca258fa33448983f6046b5b727ad1d56c27
2016-04-04 18:30:10 -04:00
stephentoub 63e8f36b90 Add CurlHandler.DefaultProxyCredentials
Commit migrated from https://github.com/dotnet/corefx/commit/256ecaf347b5e2b809722d1acbfb7bff1902bf06
2016-04-04 18:26:44 -04:00
Stephen Toub ba8bf6c2cd Add CurlHandlers.SslProtocols option
Add CurlHandlers.SslProtocols option

With libcurl on the OpenSSL backend (the recommended configuration), we can provide full-fidelity for this option.  With libcurl on another SSL backend, we can allow choosing all three TLS protcols or just one TLS protocol, but we can't support selecting two of the three.

Commit migrated from https://github.com/dotnet/corefx/commit/bd79e80f25923e0f2e29e07aba60b03070596bb4
2016-04-04 17:27:18 -04:00
stephentoub 7f83f8ddc6 Fix encoding of proxy credentials in CurlHandler
We need to URL encode the username/password for a proxy.  Otherwise, for example, a colon in the name could mess up how the concatenated username and password are parsed.  libcurl URL decodes them.


Commit migrated from https://github.com/dotnet/corefx/commit/9b4f73c0e9b4e671a2d47a5b4f53e68a9d93240d
2016-04-04 15:54:12 -04:00
stephentoub 0687204ddb Refactor HttpContent with async/await
Commit migrated from https://github.com/dotnet/corefx/commit/d44015edc83042c8b34b1cf051b9371753fdc528
2016-04-02 17:39:05 -04:00
Lakshmi Priya Sekar f452ecd1cd Fix project dependencies from the xunit extensions update.
Commit migrated from https://github.com/dotnet/corefx/commit/1939982be59ede355131c9d85684dba4b0449c50
2016-04-01 14:58:15 -07:00
Lakshmi Priya Sekar 2a3abf12b4 Update xunit.netcore.extensions to latest.
Commit migrated from https://github.com/dotnet/corefx/commit/a7bb9eb3327f5cc791d39b4cff764dd7dd29fda5
2016-04-01 14:04:56 -07:00
Jonathan Miller 0e43cc624e Merge pull request dotnet/corefx#6572 from sokket/builds
Adding builds files to the test projects

Commit migrated from https://github.com/dotnet/corefx/commit/e8326c3dab65e2e8eac466f346a9693788d41ca9
2016-03-31 11:41:43 -07:00
Jonathan Miller 7c2ce6913c Adding builds files for the test projects
Commit migrated from https://github.com/dotnet/corefx/commit/752599494fce80b5d0059a9090fdc010d8c7f45b
2016-03-31 10:46:26 -07:00
David Shulman 7eb1b02cbe Merge pull request dotnet/corefx#7302 from stephentoub/streamtostreamcopy
Improve memory usage of HttpClient's StreamToStreamCopy

Commit migrated from https://github.com/dotnet/corefx/commit/1f43828ee4797aeb434c525eb036bde1f69a5e3c
2016-03-31 09:24:01 -07:00
stephentoub 025ea3f97f Update packages to rc3-23931-00
Commit migrated from https://github.com/dotnet/corefx/commit/e421dd9c41c308f83511e350c1e407d1f728ba78
2016-03-31 08:26:49 -04:00
stephentoub 7330010faf Improve memory usage of HttpClient's StreamToStreamCopy
Copying between streams represents one of the larger sources of memory allocations and copying in HttpClient. HttpClient has its own stream-to-stream copy implementation, but there are ways we can significantly improve it based on typical usage within HttpClient.  This commit does the following:
- Previously it would special case when both the source and destination stream were MemoryStreams, but even in that case it would allocate a temporary buffer and do a Read/Write loop to copy between them, and even then it's relatively rare to copy from a MemoryStream to a MemoryStream.  Instead, if the source stream is a MemoryStream and we can get its buffer, we can do a single write to the destination (regardless of what kind of stream it is), avoiding the need for multiple read/writes and for the temporary buffer.  If we can't get its buffer but its length is known to be less than or equal to the requested buffer size and it's positioned at the beginning, we can simply ToArray the source and still do a single write to the target.
- If the destination is the special LimitMemoryStream, used for buffering output, and if that LimitMemoryStream was pre-sized based on the response having a Content-Length, then rather than allocating a temporary buffer and repeatedly copying from the source stream into that buffer and copying from the buffer into the memory stream, we can instead give the destination's buffer directly to be read into by the source, avoiding the temporary buffer and the extra copies.  This is a very common case.
- If the source does not need to be disposed after the copy, rather than doing our own copy loop, we can instead ask the source to use its CopyToAsync implementation to copy to the destination stream.  Worst case this will be exactly what we were previously doing, but best case the source has its own CopyToAsync override that's more efficient.
- When constructing a LimitMemoryStream, if the Content-Length isn't known, we were explicitly passing a 0 capacity to the base, which causes it to allocate a new zero-length array; I've added a ctor to avoid that.

Also avoids some unnecessary array allocations and copies while getting data from buffered content.


Commit migrated from https://github.com/dotnet/corefx/commit/d2502ce05032ae83c5675e2cd4b27ca2fb6706fa
2016-03-30 19:07:00 -04:00
Stephen Toub c7897db0b5 Merge pull request dotnet/corefx#7337 from stephentoub/httpclient_tests
Add more tests for HttpClient

Commit migrated from https://github.com/dotnet/corefx/commit/fc0919e2471a8b99958245dcfd23f79481c02bd9
2016-03-30 15:47:09 -04:00
stephentoub 99e0ca33de Address PR feedback
Switch to avoid network requests when possible, and bring line coverage up to 100%.


Commit migrated from https://github.com/dotnet/corefx/commit/71e246929f5ae99bbba8611b7a5239a041b94f42
2016-03-30 08:18:40 -04:00
stephentoub dabfe7fc9d Update packages to rc3-23930-00
Commit migrated from https://github.com/dotnet/corefx/commit/64a2b6c70977e33b4e8fb90e8f5d3b019b843e61
2016-03-30 07:30:59 -04:00
stephentoub a4d7a22225 Add more tests for HttpClient
To have more confidence while refactoring, added more HttpClient coverage, in particular of error paths.  Brings HttpClient line coverage from 64.7% to 98.3%, and branch coverage from 42.3% to 78.7%.


Commit migrated from https://github.com/dotnet/corefx/commit/2b88030aa1d2e7cb0b679e871fc4d0613ebbbf02
2016-03-29 19:34:21 -04:00
stephentoub d156fea268 Remove unnecessary string allocations in MultipartContent
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
2016-03-27 22:24:26 -04:00
stephentoub 753c12bd76 Ensure CurlHandler sets CBT even on fast verification path
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
2016-03-26 22:36:02 -04:00
stephentoub aa64955b41 Update packages to rc3-23925-00
Commit migrated from https://github.com/dotnet/corefx/commit/268eea1b538fa80a0042a1eabc4e51c84473d7b0
2016-03-25 20:23:47 -04:00
stephentoub 11bb3f3c94 Remove and replace some stale [ActiveIssue(...)]
Remove some stale [ActiveIssues] where the tests now pass.

Replace some others with [PlatformSpecific], where the behavior is deemed to be "by design" / accepted.

And update a few issue numbers.


Commit migrated from https://github.com/dotnet/corefx/commit/9c13b0c9389189d86fb2d270c28660946b3ae80c
2016-03-25 15:24:49 -04:00
stephentoub 57672b1925 Add assert for status code to cookies test
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
2016-03-24 19:07:44 -04:00
stephentoub e91101e062 Add tests for certificate revocation and non-OpenSSL backend
Commit migrated from https://github.com/dotnet/corefx/commit/9d4347b5bdca817937dea602f452df3fc2e9e2f3
2016-03-23 16:42:05 -04:00
stephentoub e9e2575810 Change http shim to support getting better version info
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
2016-03-23 14:10:36 -04:00
stephentoub 436bbdf105 Add HttpClientHandler tests for server certificates
Commit migrated from https://github.com/dotnet/corefx/commit/65a4486bfe44c633c2e4dad6dabc6688bea16cc2
2016-03-23 14:10:19 -04:00
stephentoub 0de8ee2b33 Update packages to rc3-23923
Commit migrated from https://github.com/dotnet/corefx/commit/123180cde4aadbed151ffbc00c09b85b7532da68
2016-03-23 11:56:57 -04:00
stephentoub b60997fa74 Update packages to rc3-23921
Commit migrated from https://github.com/dotnet/corefx/commit/3eb508d41d476e4ca0c74d106584c7a7f0d51a17
2016-03-21 12:10:10 -04:00
Jon Hanna 1c58a2a42a Fix multiple typos [5]
Commit migrated from https://github.com/dotnet/corefx/commit/00a0871c5cc4ff6af7f036946eef48644ed1e27d
2016-03-20 19:15:44 +00:00
Eric St. John 6aeccb0bae Fix tests to restore using the latest packages
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
2016-03-19 08:01:11 -07:00
Eric St. John ff75367f93 Update packages to rc3-23918
Commit migrated from https://github.com/dotnet/corefx/commit/d3d217b2ab336b862c27a3e605e32dc0c0a6d472
2016-03-19 08:01:09 -07:00
Kevin Jones c428584581 Fix typo in file name.
Commit migrated from https://github.com/dotnet/corefx/commit/af8c01f507c9227a8a11fb752c7df2142f7b4044
2016-03-18 12:45:24 -04:00
stephentoub 1cbe15bf38 Query for the right proxy creds in HttpClient
Both the WinHttp and libcurl implementations are using the target Uri to lookup the right proxy credentials rather than using the proxy's Uri.


Commit migrated from https://github.com/dotnet/corefx/commit/d0cc5116a9906834f5ebd1813c9b9eed68ea054b
2016-03-17 10:34:06 -04:00
Justin Van Patten 34d430921b HttpClient: Add comment to Set-Cookie test
Add a comment explaining the header value lengths being tested.


Commit migrated from https://github.com/dotnet/corefx/commit/2664968783439ddc3b64b99e0d42d1d293e1a082
2016-03-12 09:07:03 -08:00
David Shulman a576f9d8e1 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/ad0aa0c7f912a39275c955062e805d8853993f31
2016-03-11 07:07:20 -08:00
David Shulman 420449a472 Fix WinHttpHandler when no proxy creds after 407 response
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
2016-03-10 19:18:38 -08:00
Stephen Toub 4374bc6d33 Merge pull request dotnet/corefx#6799 from stephentoub/strip_content_headers
Remove content headers in CurlHandler when automatically decompressed

Commit migrated from https://github.com/dotnet/corefx/commit/1ca11068f411628cce053d9ef0295b80e7135d90
2016-03-10 14:54:54 -05:00
stephentoub d5e591e45a Update packages to rc3-23910
Commit migrated from https://github.com/dotnet/corefx/commit/ab3948bfab039aac2afc1b521883425a171b982d
2016-03-10 09:37:40 -05:00
stephentoub edeb083709 Remove content headers in CurlHandler when encoded
WinHttpHandler removes the Content-Length and Content-Encoding headers when the content was automatically decompressed.  Do the same in CurlHandler.


Commit migrated from https://github.com/dotnet/corefx/commit/093dafe74d53c2222ff6f434107d49205cf7fa2f
2016-03-10 08:14:59 -05:00
Justin Van Patten 0d18ce8a1d HttpClient should not miss Set-Cookie response headers
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.

Fixes dotnet/corefx#6737.


Commit migrated from https://github.com/dotnet/corefx/commit/f7e9f00aba800d2ea63e040deafcc7ee220331fc
2016-03-09 02:35:42 -08:00
Eric St. John 8cba463a08 Update crypto package dependency versions
System.Security.Cryptography.Algorithms, Cng, and X509Certificates are
now 4.1.0.  Update dependencies to ensure we get the right build.


Commit migrated from https://github.com/dotnet/corefx/commit/6e3e29dbec3705094a539b6b2dc863c5a8ee270c
2016-03-08 21:40:47 -08:00
Eric St. John 04a73fbed6 Update packages to rc3-23908
Commit migrated from https://github.com/dotnet/corefx/commit/86a230845c4f1840dcb9b52165c6976fad5b5868
2016-03-08 08:46:50 -08:00
Stephen Toub ab2ef9d0fd Merge pull request dotnet/corefx#6727 from davidsh/blank_statusdescription
HttpResponseMessage.ReasonPhrase should not be null

Commit migrated from https://github.com/dotnet/corefx/commit/3da7a023a2cf89c0a980a6c5cde25b67be530f68
2016-03-07 20:40:09 -05:00
David Shulman 1e120fdd63 HttpResponseMessage.ReasonPhrase should not be null
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.

Fixes dotnet/corefx#6721.


Commit migrated from https://github.com/dotnet/corefx/commit/19ec320403cd53ad0cba75c69a1a2c027ed867d5
2016-03-07 12:23:04 -08:00
stephentoub 38f7d19954 Update packages to rc3-23907
Commit migrated from https://github.com/dotnet/corefx/commit/baed539ebb753fefc91da9870ddeee72df0a6e14
2016-03-07 10:12:40 -05:00