Commit Graph
210 Commits
Author SHA1 Message Date
Caesar Chen 7669319f3f SocketsHttpHandler: Add workaround for ipv6 LLA address (dotnet/corefx#28971)
* add workaround for ipv6 LLA address

* address comment

* fix comment


Commit migrated from https://github.com/dotnet/corefx/commit/0698997390ddc15abb375eba73a5d712ccdb8266
2018-04-13 17:34:32 -07:00
Caesar Chen 3aab539b89 Fix proxied ipv6 address request formatting and fix port handling for proxied IP address on SocketsHttpHandler (dotnet/corefx#28740)
* fix proxied ipv6 address request format and fix port handling for ip address

* address feedback

* change naming for test data


Commit migrated from https://github.com/dotnet/corefx/commit/18d685f3b1ed8fd22601fb0bce3eb928f1c4206f
2018-04-05 15:17:20 -07:00
Paulo Janotti 9365b6fb44 Re-enable PostAsync_RedirectWith307_LargePayload dotnet/corefx#23768 (dotnet/corefx#28828)
Fixes dotnet/corefx#23768

Commit migrated from https://github.com/dotnet/corefx/commit/28dcece5c5e7d30446ae90e027076722513b716f
2018-04-04 16:54:06 -07:00
Caesar Chen 109d0485aa disable test (dotnet/corefx#28789)
Commit migrated from https://github.com/dotnet/corefx/commit/e4521cbd572764f3a140366cce7b39402e1a14cc
2018-04-03 16:49:01 -07:00
Caesar Chen 0ffc020ac5 Fix ipv6 address format in Host header (dotnet/corefx#28578)
* fix ipv6 format in host header

* address feedback

* address feedback

* fix common case

* reduce allocation

* address feedback

* fix indexof issue

* disable on curlhandler

* revert to simple fix

* address feedback and add comment

* address test issue, enable on curlhandler

* fix framework failure

* address feedback


Commit migrated from https://github.com/dotnet/corefx/commit/24889e293731f12b11f1205b641cd3e6cb3a3b90
2018-04-02 11:26:29 -07:00
Paulo Janotti c79012a5e5 CurlHandler is deadlocking like WinHttpHandler (dotnet/corefx#28587)
* CurlHandler is deadlocking like WinHttpHandler

This repros consistently for Release on High Sierra. Issue dotnet/corefx#27746 already tracks it.

* Adding a comment to clarify scope


Commit migrated from https://github.com/dotnet/corefx/commit/50d4e1ce620f26ec4aebe26c121a769fc8e724ab
2018-03-28 23:29:23 -07:00
Stephen Toub a6932f9f28 Ensure SocketsHttpHandler throws TaskCanceledExceptions instead of OperationCanceledExceptions (dotnet/corefx#28075)
To increase compatibility, as other handlers often throw the derived type instead of the base type, as a side-effect of how they were implemented.

Commit migrated from https://github.com/dotnet/corefx/commit/1f93d2a1c5f3bdeb8c091863236fe2071e5e66f5
2018-03-22 22:11:23 -04:00
Tomas Weinfurt 11740681f6 Improve HTTP proxy tests (dotnet/corefx#28048)
* refactor some proxy tests using new loppback server and new auth function

* feedback from reviews

* correct split() use. My local build did not fail for what ever reason

* disable ProxyExplicitlyProvided_DefaultCredentials_Ignored as it used to be

* refactor some proxy tests using new loppback server and new auth function

* feedback from reviews

* disable ProxyExplicitlyProvided_DefaultCredentials_Ignored as it used to be

* add test case for dotnet/corefx#27870

* skip new test on WindowNano

* add limit on Split() so it always splits to two tokens to avoid problems with : in the value

*  update Split() as it seems not all c# flavors has the righ overload

* small improvement on header split

* feedback from review


Commit migrated from https://github.com/dotnet/corefx/commit/b2a119950cb52dd744f84b552de1da2df07b937b
2018-03-22 18:01:15 -07:00
Stephen Toub 85e7f4e1aa Re-enable SocketsHttpHandler proxy test (dotnet/corefx#28186)
Commit migrated from https://github.com/dotnet/corefx/commit/089a8890c4f4d20dde6ee0ab6acfb3056f4887e6
2018-03-19 12:56:14 -04:00
Caesar Chen 9df60dc56a Make SocketsHttpHandler default Handler (dotnet/corefx#27821)
* set SocketsHttpHandler to default

* address feedback

* fix if check for 28002


Commit migrated from https://github.com/dotnet/corefx/commit/2b850f6fe5fd3171c2554da965cb07070e1d648e
2018-03-14 00:34:56 -04:00
David Shulman 0cb5ccfce2 Change behavior of SocketsHttpHandler for redirects (dotnet/corefx#28008)
When exceeding the max number of redirecs, .NET Framework will
not throw an exception. Instead, it will return the 3xx response.
This PR changes the behavior of SocketsHttpHandler to match.

Fixes dotnet/corefx#27285


Commit migrated from https://github.com/dotnet/corefx/commit/6e3a4143c221cba5f0f1b433b96477d24b7e9b02
2018-03-13 12:02:18 -07:00
Max Kerr 9485277884 CurlHandler: Remove Transfer-Encoding on redirect from POST to GET (dotnet/corefx#27988)
This fix removes the TransferEncoding header from a request when it is redirected from POST to GET.

Fixes: dotnet/corefx#27301

Commit migrated from https://github.com/dotnet/corefx/commit/94e4bc6e888825d2ad8f373c9bbc1b279608349b
2018-03-13 09:55:36 -07:00
Stephen Toub 700bbfd8dd Change CurlHandler to only request HTTP/2 over TLS (dotnet/corefx#27934)
* Change CurlHandler to only request HTTP/2 over TLS

* Add test that 2.0 request with http:// doesn't request Upgrade


Commit migrated from https://github.com/dotnet/corefx/commit/431475b8e5462fe7d6cf9e8d424d6624c08d6a3f
2018-03-12 12:46:09 -04:00
Stephen Toub a04cb1ef89 Disable hanging Proxy_UseSecureProxyTunnel_Success test on netfx (dotnet/corefx#27815)
Commit migrated from https://github.com/dotnet/corefx/commit/2660a4690f70c6278cbdb5564c3e62e51cc1a651
2018-03-07 09:52:11 -05:00
Geoff Kizer d02b3a1091 Merge pull request dotnet/corefx#27748 from geoffkizer/testplatformfixes
fix some conditional test logic related to SocketsHttpHandler

Commit migrated from https://github.com/dotnet/corefx/commit/0ad6968adb463fa1470ba4af09f270311c8a25a3
2018-03-05 19:31:46 -08:00
Geoff Kizer e83463359d fix some conditional test logic to ensure we're not disabling SocketsHttpHandler tests
Commit migrated from https://github.com/dotnet/corefx/commit/c2db57418b02cb03c2f27a38567d86436746a275
2018-03-05 14:22:55 -08:00
Stephen Toub 38cfd8b969 Add folded response header support to SocketsHttpHandler (dotnet/corefx#27727)
* Add folded response header support to SocketsHttpHandler

The feature is deprecated by RFC 7230, but some servers still utilize it, and if they do, SocketsHttpHandler currently fails (WinHttpHandler and the netfx handler both allow it, CurlHandler currently fails as well).  This commit updates the header parsing logic to allow for them.

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/dc355e96d61d98dee48a809571edda3c1c7e5525
2018-03-05 15:32:52 -05:00
Stephen Toub 7482b6a4b0 Expose and roll out ValueTask extensibility
This commit does several things:
- Exposes the new `ValueTask` extensibility model being added in coreclr.  The ValueTask-related files will separately be mirrored over to corefx to enable the netstandard build of System.Threading.Tasks.Extensions.
- Adapts all `Stream`-derived types to return `ValueTask` instead of `Task` from `WriteAsync`.
- Changes the new `WebSocket` `SendAsync` method to return `ValueTask` instead of `Task`, and updates the `ManagedWebSocket` implementation accordingly.  Most `SendAsync`s on `ManagedWebSocket` should now return a `ValueTask` that's either completed synchronously (no allocation) or using a pooled object.  It now uses the underlying transport's new `WriteAsync` overload that returns `ValueTask`.
- Switches more uses of `ReadAsync` and `WriteAsync` over to the new overloads, including in Process, DeflateStream, BrotliStream, File, HttpClient, SslStream, WebClient, BufferedStream, CryptoStream,
- Removed some unnecessary array clearing from various routines using ArrayPool (after the clearing was added we changed our minds and decided clearing was only necessary in very specific circumstances)
- Implements a custom `IValueTaskSource` in Socket, such that async receives and sends become allocation-free (ammortized).  `NetworkStream` then inherits this functionality, such that its new `ReadAsync` and `WriteAsync` are also allocation-free (in the unbounded channel implementations; we can subsequently add it in for bounded).
- Implements a custom `IValueTaskSource` in System.Threading.Channels, such that reading and writing are ammortized allocation-free up to one concurrent reader and writer.
- A few random things I noticed as I was going through, e.g. missing ConfigureAwait, some incorrect synchronization in tests, etc.
- Adds a ton of new tests, mainly in System.Threading.Tasks.Extensions, System.Threading.Channels, and System.Net.Sockets.


Commit migrated from https://github.com/dotnet/corefx/commit/6d1671b2cfcf130b7bc6c059bb0508073426532a
2018-03-02 09:56:25 -08:00
Geoff Kizer fe3585d9c5 Merge pull request dotnet/corefx#27220 from wfurt/ssl_Proxy2
support for CONNECT method in SocketHttpHandler 

Commit migrated from https://github.com/dotnet/corefx/commit/8e88850940605ef7d57cfc7b570bdf9bf2b8d822
2018-02-24 22:20:16 -08:00
Geoff Kizer 10fb7486c6 add issue number
Commit migrated from https://github.com/dotnet/corefx/commit/cc8db63f8688043306088b0057b05f69aa23e921
2018-02-24 14:52:34 -08:00
Geoff Kizer 9dba5b8340 revert change to existing redirect test and split into new test, disabled for WinHttpHandler
Commit migrated from https://github.com/dotnet/corefx/commit/edfa136cb9b003ac5575f9d1ad3e11dfbc147d76
2018-02-24 14:30:04 -08:00
Tomas Weinfurt 73922f6a6f update AllowAllCertificates so it works on systems with curl/nss. Disable test on Windows as it seems to cause some troubles.
Commit migrated from https://github.com/dotnet/corefx/commit/85756b823938ca5c5f6583d024a14363ad266f7d
2018-02-23 10:13:47 -08:00
Tomas Weinfurt 96d06a74f6 refactor Proxy_UseSecureProxyTunnel_Success little bit.
Commit migrated from https://github.com/dotnet/corefx/commit/9fa2b9ab41d361cb1e683a95585abd91f147c67b
2018-02-22 20:37:04 -08:00
Geoff Kizer 8df3174c2f Merge pull request dotnet/corefx#27377 from geoffkizer/redirecttestfix
add shutdown call to try to make redirect test more reliable

Commit migrated from https://github.com/dotnet/corefx/commit/59481ca56906713ef9e5e4890388f4cd2fe9c699
2018-02-22 15:57:26 -08:00
Tomas Weinfurt 3a42fc41f9 Merge branch 'master' of https://github.com/dotnet/corefx into ssl_Proxy2
Commit migrated from https://github.com/dotnet/corefx/commit/f909b9f95f099a197e7bb04479b930f0e596dfb7
2018-02-22 15:36:16 -08:00
Geoff Kizer 286740559c add shutdown call to try to make redirect test more reliable
Commit migrated from https://github.com/dotnet/corefx/commit/11a9368d1b1fbf0eca11406473e1e7f0c712ff3c
2018-02-22 12:03:09 -08:00
Stephen Toub 0365092b59 Disable SocketsHttpHandler's concurrent content sends (dotnet/corefx#27341)
* Disable SocketsHttpHandler's concurrent content sends

SocketsHttpHandler currently has some support for allowing request content sending to run concurrently with response content receiving.  However, we don't actually have a need for this, and there are a lot of subtleties that would need to be made robust, e.g. how to handle exceptions that occur concurrently in the sending and receiving.  For now, we're removing it.  Unless ExpectContinue is set to true, we just send the content before receiving the response, and if it is set, we start the send and then wait for it once we've received the final status code from the server.

* Address PR feedback


Commit migrated from https://github.com/dotnet/corefx/commit/fecb772f0607dc85afdb782eda1b42ddffcba61b
2018-02-22 14:58:19 -05:00
Stephen Toub 3c9dd1b90a Fix fragment handling in HttpClient (dotnet/corefx#27360)
* Fix fragment handling in HttpClient

SocketsHttpHandler isn't sending fragments, nor is it properly inheriting the fragment from the original request URI into the redirect location URI when the original URI had one and the redirect URI did not, even though RFC 7231 says it must.  This commit fixes that for SocketsHttpHandler.

WinHttpHandler also isn't handling this inheritance according to the RFC. It appears that the logic for WinHttpHandler would actually need to be changed in WINHTTP itself, or else WinHttpHandler would need to be changed to do the redirects itself.

Neither CurlHandler or NetFxHandler send fragments at all.

This commit also fixes the test to correctly compare the expected and actual Uris... apparently Uri equality doesn't factor in fragments, so they're first converted to strings.  It also updates the test to also validate that the server received the URI with the fragment included.

* Disable the fragments test on WinHttpHandler

Apparently it sometimes doesn't do the "right thing" even in other cases.


Commit migrated from https://github.com/dotnet/corefx/commit/a273be657f6666e333fd902965a56046d6f48018
2018-02-22 14:25:05 -05:00
Geoff Kizer c3645e3634 reconcile merge and fix curl issue
Commit migrated from https://github.com/dotnet/corefx/commit/4a779f45ac9475925a967a0b9ce3f9bd277fd041
2018-02-20 15:28:05 -08:00
Geoff Kizer cde1aa194a address review feedback and fix issue with redirect to GET handling
Commit migrated from https://github.com/dotnet/corefx/commit/37baaf29aabfd4bea4e1912b5a672a8c7af79c20
2018-02-20 15:28:05 -08:00
Tomas Weinfurt 220c12eeac use TestHelper.AllowAllCertificates for validation callback to pass test netfx
Commit migrated from https://github.com/dotnet/corefx/commit/df7eaef7f46fad8520c9ee7273b06eada2f6bdf6
2018-02-20 13:04:40 -08:00
Tomas Weinfurt a9426f88e7 update tests
Commit migrated from https://github.com/dotnet/corefx/commit/12d26820d9f85c6a64a6d753956bb41a32705056
2018-02-20 10:48:10 -08:00
Caesar Chen 987d73a579 Enable SendReceive_VaryingLengthBuffers_Success on Windows run (dotnet/corefx#27181)
* enable test on Windows run

* delete script

* disable test issue dotnet/corefx#27211

* disable test see dotnet/corefx#27217


Commit migrated from https://github.com/dotnet/corefx/commit/d3a69ff4448a0bd4df12e6af481898825c066c67
2018-02-16 16:03:46 -08:00
Stephen Toub b6b2da9344 Improve test coverage of SocketsHttpHandler (dotnet/corefx#27135)
* Improve test coverage of SocketsHttpHandler

Used code coverage information to write targeted tests to cover various uncovered paths in SocketsHttpHandler.  Along the way fixed a variety of issues relating to throwing the wrong exception type, a stack overflow due to an unexpected recursive call, etc.

* Address PR feedback

* Re-disable a test


Commit migrated from https://github.com/dotnet/corefx/commit/39677219aaeab8c6591b625ab2874acb17eaf4ef
2018-02-16 12:02:45 -05:00
Geoff Kizer bf6635fcfd add response generation overloads
Commit migrated from https://github.com/dotnet/corefx/commit/6943fc7c0e92359e6335a618f6ff5ee8402af4ac
2018-02-13 16:04:26 -08:00
Geoff Kizer c9a61b410b address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/6ab005635528a03daa52ca727a4a74dcc0316830
2018-02-13 15:44:00 -08:00
Geoff Kizer b94eefba0f reorganize and cleanup some LoopbackServer code
Commit migrated from https://github.com/dotnet/corefx/commit/ec6a7215bb28a061d2357d8c3874447bc575132d
2018-02-13 15:43:59 -08:00
Max Kerr 717083f0d4 Clear Authorization Headers on Redirect (dotnet/corefx#26864)
When a user has added an Authorization header to a request via the HttpClient DefaultRequestHeaders Authorization field, ensure that header is stripped on redirect.

This change adds a method to strip Authorization headers that were set via the HttpClient DefaultRequestHeaders Authorization field, and calls that method on redirect. In addition, it adds a test to ensure that this behavior occurs as expected.

The new method ResetAuthRequestHeaders is based on the method ResetCookieRequestHeaders, which is used to reset cookie headers on redirect.

The issue also occurs in CurlHandler, but the fix is slightly different. Rather than remove the headers that have already been set, we can instead just skip them when copying over the new headers to the redirected request.

Fixes dotnet/corefx#26426

Commit migrated from https://github.com/dotnet/corefx/commit/7e6396b2bcb4d372b199cfb7b3b13e290c441124
2018-02-12 11:28:09 -08:00
Geoff Kizer 2927c099bf Merge pull request dotnet/corefx#26989 from geoffkizer/fixcookiehandling
SocketsHttpHandler: Fix some issues with cookie handling, and add cookie tests

Commit migrated from https://github.com/dotnet/corefx/commit/8cee267154ef9dc6dde7a76a828844a200437872
2018-02-11 18:23:50 -08:00
Geoff Kizer ef25741e58 consolidate cookie tests
Commit migrated from https://github.com/dotnet/corefx/commit/c20262c69a93449498d511014e9e69bad18f987a
2018-02-11 12:38:20 -08:00
Stephen Toub 5c894d6b17 Add SocketsHttpHandler check for TransferEncodingChunked w/o Content (dotnet/corefx#27040)
Commit migrated from https://github.com/dotnet/corefx/commit/bf5a3183bc901723ebe0bb3d178bec86cda57429
2018-02-11 12:19:03 -05:00
Stephen Toub 296015a364 Add more SocketsHttpHandler tests
Commit migrated from https://github.com/dotnet/corefx/commit/8cb4d130bc3e8151fc72fe9494787643c7b00c4b
2018-02-08 19:12:50 -05:00
Stephen Toub 89dfde815e Expose SocketsHttpHandler
- Renames ManagedHandler to SocketsHttpHandler
- Moves a bunch of files around accordingly
- Updates System.Net.WebSockets.Client to use SocketsHttpHandler directly
- Updates System.Net.Http's tests with a reflection-based rather than TLS-based method for instantiating an HttpClientHandler backed by a SocketsHttpHandler.


Commit migrated from https://github.com/dotnet/corefx/commit/852d40e723c849e8d0c486676d40332343e12ca5
2018-02-08 19:12:50 -05:00
Stephen Toub 458c3f858c Implement MaxResponseHeadersLength on ManagedHandler (dotnet/corefx#26906)
Commit migrated from https://github.com/dotnet/corefx/commit/b6b7eb09600c18d35c6f9bf9ca484d5b8399f718
2018-02-07 17:58:05 -05:00
Geoff Kizer 507363f7c1 Merge pull request dotnet/corefx#26782 from geoffkizer/httpmisc2
ManagedHandler: support LF line endings and trailer headers

Commit migrated from https://github.com/dotnet/corefx/commit/ddf2a6d45973d5ceb6b2c9920a23f64094c6da3c
2018-02-07 00:12:58 -08:00
Paulo Janotti d88807b6d4 Conditionally skip test causing assert in WSL. (dotnet/corefx#26875)
Skip test in WSL until dotnet/corefx#26813 and dotnet/corefx#26476 are fixed

Commit migrated from https://github.com/dotnet/corefx/commit/d9665c946e47dc9a3cf4b4669d73f9d49a752a68
2018-02-05 21:40:59 -08:00
Stephen Toub 114398ac6b Disable ExpectContinue in ManagedHandler when using version 1.0 (dotnet/corefx#26774)
Don't fail, but disable sending the header and respecting the setting if the version is 1.0.

Commit migrated from https://github.com/dotnet/corefx/commit/8ec2cf215893c1f86c25bc079ff67e67678e0a04
2018-02-03 06:07:36 -05:00
Paulo Janotti 64e492d841 Fix test PostAsync_ThrowFromContentCopy_RequestFails (dotnet/corefx#26794)
* Fix test to catch proper exception according to handler

* Removing test trait added for my local tests

* Uap handler behaves like the managed one

* Switch if branching for simpler condition


Commit migrated from https://github.com/dotnet/corefx/commit/f38afda24305979be4613d08df8ea154a6a2d16d
2018-02-02 19:07:29 -08:00
Stephen Toub b3286ea024 Clean up ManagedHandler sending of request content (dotnet/corefx#26759)
* Clean up ManagedHandler sending of request content

Centralize the copy into the function that actually sends the content.

* Add HttpClientHandler test for handling request content copy failure


Commit migrated from https://github.com/dotnet/corefx/commit/6f8a600be95671162bd4de3014adafabe0a0e5ed
2018-02-02 08:50:35 -05:00
Geoff Kizer 1869a9d1a1 support LF line endings and trailer headers
Commit migrated from https://github.com/dotnet/corefx/commit/85c943fb8388585a7d49a75b879844d68962a6ab
2018-02-02 01:21:27 -08:00