Commit Graph
35 Commits
Author SHA1 Message Date
Geoff Kizer 834b812e22 remove handler dependency in HttpClientTest
Commit migrated from https://github.com/dotnet/corefx/commit/93719a61bb57729d940a8f20d7884e06dd935af7
2019-01-09 02:32:23 -08:00
David Shulman da166250dc Fix networking tests to work against NETFX (dotnet/corefx#31397)
Several of these tests were disabled because they failed on NETFX. This PR adjusts the tests
to work properly on NETFX due to some differences in behavior from .NET Core.

Fixes dotnet/corefx#28882

Commit migrated from https://github.com/dotnet/corefx/commit/f5a165540c4067b8fe0635b9beb6102d0b1d87a3
2018-07-29 07:57:08 -07:00
Santiago Fernandez Madero ccdea37829 Update netfx alias to target .NET 4.7.2 (dotnet/corefx#28883)
* Change netfx to target .NET 4.7.1

* Fix CoreFx.Private.TestUtilities to not reference System.Runtime.InteropServices.RuntimeInformation which is now inbox in netfx

* Fix StackTrace.Tests to be built against netstandard and run against netfx inbox

* Fix ValueTuple configurations to support net461 and add netfx placeholder configuration since in net471 it is now inbox

* Fix projects' package configurations that had netfx (net461) to still support net461 and netfx as a buildconfigurations

* Disable failing tests when running on .NET 4.7.1

* Make netfx target net472 and merge with master

* Update ActiveIssue comments to issue number only

* Workaround packages tests due to not installed targeting pack

* Match NSSupportPackage version to CLI's

* Remove netstandard support lib bin placing to runtime and testhost for netfx, fix reference paths to match new package

* Run UpdateVSConfigurations after merging conflicts with the newly updated SDK projects

* Add net461 package configuration to System.CodeDom

* Add net461 package configuration to System.Configuration.ConfigurationManager

* Add net461 package configuration to System.Security.Cryptography.Xml

* Add net461 package configuration to System.Security.Permissions

* Add net461 package configuration to System.ServiceModel.Syndication


Commit migrated from https://github.com/dotnet/corefx/commit/faad2e63b35bed10fe18195987a413308b97eded
2018-07-10 15:04:27 -07:00
Krzysztof Wicher c2f3338220 Handle User-Agent/Server writing similarly to HttpHeaders.GetHeaderString (dotnet/corefx#28994)
* Handle User-Agent/Server writing similarly to HttpHeaders.GetHeaderString

* add a testcase and comment for user-agent writing

* apply feedback

* further simplify test

* Update HttpClientTest.cs


Commit migrated from https://github.com/dotnet/corefx/commit/b703f310d5330bad7ae4b571175f259a3a1bc4b0
2018-04-11 01:37:40 -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
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
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 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
Tyler Brinkley 9d61820b00 Made tests only apply to netcoreapp
Commit migrated from https://github.com/dotnet/corefx/commit/dff5efc1c3630e40c961d01049afd35475a29221
2018-01-01 21:00:31 -06:00
TylerBrinkley 9bfaec2d68 Added functional tests.
Commit migrated from https://github.com/dotnet/corefx/commit/d67255e150d3a12cabdc832c523be1c79db53e03
2017-12-22 13:53:08 -06:00
Stephen Toub 7be9b5bb5f Switch tests to use thread-local switch for ManagedHandler
And as a result re-enable parallelism of the test suite, which on my machine reduces the running time of the outerloop tests from 150s to 45s.


Commit migrated from https://github.com/dotnet/corefx/commit/3db504ec31fb03162b33e0658870aef5af4e4abe
2017-09-21 08:26:44 -04:00
Stephen Toub 8bfc1f89b1 Fix potential deadlocks in HttpClient tests
A bunch of tests have the following structure:
```C#
var clientTask = hc.GetAsync(...);
await server.HandleRequest();
Handle(await clientTask);
```
If the HttpClient request fails in a way that causes the server not to receive the request, the test will hang, as the await for the server operation to complete will never complete.

This commit changes a bunch of the tests to avoid that pattern.  This makes several of the tests disabled due to hanging actually reveal the cause of the problem, e.g. the ManagedHandler not supporting 1.0 requests and failing immediately if provided with that version without making a request to the server.


Commit migrated from https://github.com/dotnet/corefx/commit/e34b6fd99085c69c8fd7a64ed5eb4da5b66f4136
2017-08-11 15:34:06 -04:00
Stephen Toub d0331b469f Fix MaxResponseContentBufferSize handling (dotnet/corefx#21145)
It's not causing failures in all cases it should, as it's comparing against a buffer size that may have grown to be larger than the desired max.

Commit migrated from https://github.com/dotnet/corefx/commit/517b9dd71b83659b4ce5fbd7f4fe1b749a7579b1
2017-06-16 21:54:25 -04:00
Stephen Toub 9401004824 Stop disposing of request content in HttpClient
HttpClient on Unix fails for some sites, in cases where the site sends a response before it’s fully received the entirety of the request.  That’s because HttpClient has logic to Dispose of the request content once the Task returned from the handler’s SendAsync completes, and unlike WinHTTP, libcurl doesn’t require that the whole request be sent before any of the response is processed.  That means that CurlHandler may receive the response (or the response headers), complete the SendAsync task, but still be reading from the request content, which may then be disposed of by HttpClient while it’s still in use, causing potential corruption, exceptions, etc.

The Dispose behavior has other problems with it.  A more generalized version of the above is that it prevents handlers that want to support full duplex communication, since it essentially requires that the whole request be sent before the response is processed.  It also forces extra cost onto consuming code in some situations, as it means that the request content objects can’t be pooled and reused (since disposal typically invalidates objects for such a purpose, though in some cases a custom content could be developed to override and ignore Dispose).

A variety of approaches were explored to address this:
- Change CurlHandler to only complete the SendAsync Task when both the request has been fully sent and the appropriate portion of the response has been received.  This is problematic, though, as with the pull model employed by libcurl, we don’t know reliably when the request has been fully sent.
- Change the disposal to be handled by the handlers rather than by HttpClient.  This could help in that a handler like CurlHandler could simply defer disposal until libcurl tells it the “easy” operation is done.  But it has other downsides. Today code can use an HttpClientHandler without HttpClient, e.g. by using HttpMessageInvoker instead of HttpClient, in which case it bypasses this disposal logic (and other logic provided by the relatively thin HttpClient wrapper). If we were to move the disposal logic to the HttpClientHandler, now such code that was never having its request content disposed will start to, which is bad and exactly the opposite of what we want. It also causes problems for chains of handlers, e.g. if HttpClient is given a handler that wraps CurlHandler, and that handler expects to be able to look at the request content after the SendAsync Task from CurlHandler completes but before it itself completes its SendAsync Task. And while such a scenario may seem far fetched, we effectively have it in the bits today: the diagnostic handler that's used to pass details off to DiagnosticListeners is injected in the middle like this, and it does pass off the request content after the wrapped SendAsync Task completes... if a listener was expecting a non-disposed request content at that point, it would be sorely disappointed.
- Simply stop disposing.  The primary downside here is existing code that may have expected disposal to happen, e.g. if a StreamContent wrapping a FileStream isn't explicitly disposed of by the app code, cleanup of the FileStream will be left to its finalizer.

The least bad option is to simply stop disposing.  This PR makes that change.


Commit migrated from https://github.com/dotnet/corefx/commit/6d06c39857f8bb7a798ca118944d25a43aaa8beb
2017-04-28 07:13:43 -04:00
David Shulman 3505e5abfd Root cause System.Net.Requests test failures on NETFX
Finished investigation of failures on .NET Framework for
System.Net.Http.

Added specific NETFX test changes where necessary. Opened up additional
bugs for investigation.

Added missing parameter validation for HttpClientHandler.MaxConnectionsPerServer
for the net46 OOB. This matches .NET Core now.

Removed some test code that was incorrectly trying to do CredentialCache.Add()
with a 'basic' authtype and using DefaultCredentials. This is invalid and
throws exception on netfx. Added dotnet/corefx#18870.

Remove PlatformNotSupportedProxy test code. It was throwing an exception
on netfx and the purpose of it didn't seem to make sense in the one test
that was using it.

Fixes dotnet/corefx#17691.


Commit migrated from https://github.com/dotnet/corefx/commit/b1246c7f1ee1d9e42594988073fd06580d23fe84
2017-04-24 14:09:31 -07:00
Daniel Harvey 252cdc5e95 Bulk updates of tests for AssertExtensions (dotnet/corefx#18491)
Bulk update to AssertExtensions.Throws for AOT support. This doesn't disable Assert.Throws.

Commit migrated from https://github.com/dotnet/corefx/commit/b43b4df2e0e2182154bb0f425cb4a61bc1269828
2017-04-18 09:52:02 -07:00
David Shulman 75d4e8ad18 Fixes for running Http tests against Desktop
Got the Http Functional tests running with no errors against NETFX (Desktop). Found a bunch
of compatibility differences between Desktop and Core that need to be investigated. For now,
the tests are skipped on Desktop.

Fixed the LoopbackServer so that it will run. It was blowing up with `MissingTypeException`
due to missing SocketTaskExtensions class (dotnet/corefx#17690).

Contributes to dotnet/corefx#17691


Commit migrated from https://github.com/dotnet/corefx/commit/b7f6f5f159ebe6c0597578bbd858697a6159a22f
2017-04-01 09:28:32 -07:00
Stephen Toub f940c093c7 Change HttpClient timeout test to use loopback server
Shorten test duration from 40 seconds to .5 seconds


Commit migrated from https://github.com/dotnet/corefx/commit/e323ff698267e22df01cb10beb49fa24eecebcce
2017-01-26 19:22:02 -05:00
Ian Hays 3cebd64914 Increase timeouts for some failing Net tests
These two tests are/were failing intermittently from hitting their timeouts. We can increase those timeouts to a significantly higher value without taking away from the test's value.


Commit migrated from https://github.com/dotnet/corefx/commit/fcc9f8023490f07a82886cf504f754dc24bc4b9b
2017-01-25 12:15:26 -08:00
David Shulman 13c6b6c2e7 Disable tests to unblock CI
Disabling tests for dotnet/corefx#12637 and dotnet/corefx#12778.


Commit migrated from https://github.com/dotnet/corefx/commit/597ef01e84cfb6cc1c4dda25500e07b27c8e144c
2016-10-31 11:26:55 -07:00
Eric St. John f6f23740a5 Update Http tests to target ns1.7 + ns1.3
I had to add a namespace alias due to System.Configuration now being
defined by System.Runtime.


Commit migrated from https://github.com/dotnet/corefx/commit/6e86da5cc3efb88db6b932f01c9a4f9e66e84f8c
2016-10-20 14:31:18 -07:00
Cristian Pop 7a3d76b180 Adding multi-machine scripts and unifying configuration.
Commit migrated from https://github.com/dotnet/corefx/commit/c354b2d44f6988a20a9f7be4a1b996ef7fbc873a
2016-06-28 12:38:07 -07:00
Stephen Toub 7295751d20 Separate diagnostics tests into their own class
The only change to the logic is that the tests now use RemoteInvoke to run each test in its own process, so as to avoid EventSource and DiagnosticSource interference.

Also removed the xunit attributes from the assembly that prevented parallelization.  It's no longer needed as of this change.


Commit migrated from https://github.com/dotnet/corefx/commit/542d85e15bfe5fdeb59d7e6f7fb3b15a08640ebd
2016-06-20 14:13:10 -04:00
Stephen Toub 2424c43e44 Improve tracing in CurlHandler
While debugging some HttpClient issues, I needed more tracing in CurlHandler.  It's useful to check this in to help with future investigations.


Commit migrated from https://github.com/dotnet/corefx/commit/48da5807ac281c26b34ac375755a4d83b2268a91
2016-05-27 13:19:45 -04:00
stephentoub 5ffbace49b Fix HttpClient test hanging on single core
One of the HttpClient client tests hangs on a machine with a single core.
xunit by default uses a SynchronizationContext that has N threads to do
work, where N defaults to Environment.ProcessorCount.  Thus on a single
core machine, there's only one thread available to run tests, and if that
thread blocks waiting for an async operation that'll schedule work back to
that context, it'll deadlock.


Commit migrated from https://github.com/dotnet/corefx/commit/916798757c122b81e61666c4f0af0c446d378824
2016-05-11 15:05:14 -04:00
Eric Eilebrecht 13d2049dc6 Remove TODO comment
Timeouts like these aren't uncommon in the System.Net test code.


Commit migrated from https://github.com/dotnet/corefx/commit/fd2fa174bb59b768f63225fde5bdde31c97313e4
2016-04-20 10:05:35 -07:00
Eric Eilebrecht 3bd2cecc8d Replace TODO with more relevant TODO referencing dotnet/corefx#2383
This matches the similar comment elsewhere in this file.


Commit migrated from https://github.com/dotnet/corefx/commit/fb891c4df14a0224e4b8cedb99c68e26ed05c855
2016-04-20 10:05:34 -07: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 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 b6b5cfd1c0 Fix HttpClient diagnostic listener issues
- 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
2016-02-16 18:13:49 -05:00
nbilling 4401926ae3 Http request/response DiagnosticSource logging.
- Added logging to WinHttpHandler, CurlHandler, and HttpHandlerToFilter
  for HTTP request/response.
- Added functional tests for HttpClient (WinHttpHandler is exercised by
  these tests on desktop).


Commit migrated from https://github.com/dotnet/corefx/commit/edbd7ba720699bbe20753872ac430f0b3fdaf3a9
2016-02-16 15:57:17 -05:00
Cristian Pop 01d61b736f Fixing and adding tests for the in-memory VirtualNetwork/Stream. Adding
TaskTimeoutExtensions and fixing the System.Net.Security timeout pattern.


Commit migrated from https://github.com/dotnet/corefx/commit/27954497d635ff0f01fbb16e1b485156c51398ea
2016-02-08 16:02:01 -08:00
dotnet-bot 39d1eab950 Update licensing headers
Commit migrated from https://github.com/dotnet/corefx/commit/7cad8486cbabbce0236bdf530e30db7036335524
2016-01-27 08:02:28 -08:00
David Shulman 9d997536f4 Port additional System.Net.Http tests to CoreFx
Added more http tests to open source from the original internal ToF tests. Some of
the tests should be refactored in the future to avoid Assert'ing multiple
logical things.

Fixed up test namespaces for System.Net.Http and
System.Net.Http.WinHttpHandler.


Commit migrated from https://github.com/dotnet/corefx/commit/e5a017cb6ca01e99b1f1462298bc0cbf60c06ee0
2015-09-21 11:48:34 -07:00
David Shulman 54525a2a94 Fix HttpClientHandler timeouts
Since HttpClientHandler doesn't expose all the timeout used by the
underlying WinHttpHandler, we need to disable those timeouts in favor of
the HttpClient.Timeout property.

Addresses issue dotnet/corefx#2857.


Commit migrated from https://github.com/dotnet/corefx/commit/86e89f73a1e7bf5b4fd40878f4fec4741a8651ca
2015-08-26 10:15:34 -07:00