Commit Graph
269 Commits
Author SHA1 Message Date
stephentoub 514492a454 Don't cancel all requests when HttpClient disposed on Unix
On Unix when an HttpClientHandler is disposed, we cancel all outstanding operations associated with that handler.  It turns out this isn't the desired behavior (aka the behavior of WinHttpHandler), which is that we should cancel all outstanding operations that haven't yet published its HttpResponseMessage, but for requests where the HttpResponseMessage has been published, it should remain valid.

This commit tweaks the behavior accordingly and adds a test for it.


Commit migrated from https://github.com/dotnet/corefx/commit/f949d92b3ee26168277f56fbd2c6686505ea0b4a
2016-05-12 14:27:51 -04:00
stephentoub 08c45ba7b8 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/10c8af5ebedaf1db4a2a7efeac58518df362cbdf
2016-05-12 06:11:28 -04:00
stephentoub 31eddcd4ce Add HttpClient test with IPv6 Uris
Adds support to the loopback server for binding to IPv6 local addresses, then adds a test that uses both ::1 and a link-local address for the current machine.


Commit migrated from https://github.com/dotnet/corefx/commit/a00e71b22fecbf9e2da3205e2e56bdb46773cbc2
2016-05-12 06:11:28 -04:00
dotnet-bot ce3a923ef2 Updating CoreFX dependencies to rc3-24112-00
Commit migrated from https://github.com/dotnet/corefx/commit/388140d1885acee4019544e4b9f8ccb6dd4310d6
2016-05-12 05:51:26 +00: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
David Shulman 71f781e3c2 Improve WinHttpHandler logic regarding default credentials (dotnet/corefx#8434)
* Improve WinHttpHandler logic regarding default credentials

In some cases, WinHttpHandler was not sending default credentials that were specified inside a custom ICredentials object. In other cases, default credentials would be sent even though CredentialCache.DefaultCredentials was not specified. The code was incorrectly comparing the proxy and server credential (ICredential interface) values against the DefaultCredentials object. Instead, the ICredentials.GetCredential() method should be called to compute the final NetworkCredential object. This takes into account the given uri and auth scheme.

This PR fixes the logic by delay the setting in WinHTTP for releasing default credentials. This ensures that default crdentials are released when requested.

Fixes dotnet/corefx#8176.

* Address PR feedback

Reword comments for clarity.
Add TODO issue.
Sending default creds to proxy only needs MEDIUM security policy.


Commit migrated from https://github.com/dotnet/corefx/commit/90b8ff36c8c9f9cfb1a2cf1302ff7a98ac7801ed
2016-05-11 07:01:41 -07:00
stephentoub bb56a66ba5 Updating CoreFX dependencies to rc3-24111-00
Commit migrated from https://github.com/dotnet/corefx/commit/3b49a7960613e27f89538a53a893a0f8fbb74593
2016-05-11 06:47:29 -04:00
Stephen Toub 0852be942c Merge pull request dotnet/corefx#8442 from dotnet-bot/UpdateDependencies20160511120846
Updating CoreFX dependencies to rc3-24110-00

Commit migrated from https://github.com/dotnet/corefx/commit/44dd3f7a997f560d05e7d43b773b63dd756ac51a
2016-05-11 06:18:49 -04:00
stephentoub ac19b4db8b Disable two recently added tests
These were both added in the last few days and have both failed in CI at least once.


Commit migrated from https://github.com/dotnet/corefx/commit/e3f64a9c8f3869f3db1bdc7bac496e56b89334a6
2016-05-10 22:55:55 -04:00
dotnet-bot bb2d7075e5 Updating CoreFX dependencies to rc3-24110-00
Commit migrated from https://github.com/dotnet/corefx/commit/2c092dd2f1ede076753ffee8342a4e04f919b89a
2016-05-11 00:08:46 +00:00
Stephen Toub 255d5a328b Merge pull request dotnet/corefx#8377 from stephentoub/ssl_loopback_server
Add SSL support to LoopbackServer in HTTP tests

Commit migrated from https://github.com/dotnet/corefx/commit/dbdae6947381db563b081fe7dbcf116ff9df36bc
2016-05-10 17:50:29 -04:00
stephentoub b8970ee51b Add SSL support to LoopbackServer in HTTP tests
We currently make a lot of calls off-box in our unit tests.  By adding SSL support to the loopback server, we should be able to convert many more tests to avoid needing to actually hit the network.  This adds such basic support, and converts a few tests to use it.

Also, since I was moving the certificate configuration code to a central location, I fixed an issue related to cleanup.


Commit migrated from https://github.com/dotnet/corefx/commit/b90795e1d5d7e8d8c68b9ca23d53b1ba0e392f46
2016-05-10 13:55:40 -04:00
stephentoub ce065a4145 Disable ConnectTimeoout test on Linux
It's failing on Ubuntu 16.04.  Something about the curl used in CI is likely wrong.


Commit migrated from https://github.com/dotnet/corefx/commit/2871273e752dfda09427fb627e590de29bff61a8
2016-05-10 06:42:08 -04:00
stephentoub 9a7efb22cf Disable BadCertificate test failing on Windows
Commit migrated from https://github.com/dotnet/corefx/commit/69652b53d1fa4d1a71bfe4271e22ededebd6c73b
2016-05-09 14:13:57 -04:00
dotnet-bot 9829ded094 Updating CoreFX dependencies to rc3-24109-00
Commit migrated from https://github.com/dotnet/corefx/commit/a0ae8adee8b9454180c3e1f9416f28964b6eccb3
2016-05-09 06:40:00 +00:00
Stephen Toub 2ba22663db Merge pull request dotnet/corefx#8363 from dotnet-bot/UpdateDependencies20160506101302
Updating CoreFX dependencies to rc3-24106-00

Commit migrated from https://github.com/dotnet/corefx/commit/6c257e74fff7cda64fc3a069572007f4b038e057
2016-05-08 20:28:38 -04:00
Stephen Toub 6b493b1bdf Merge pull request dotnet/corefx#8177 from stephentoub/avoid_queued_copytoasync
Avoid race condition between queued HttpContent.CopyToAsync and request completion

Commit migrated from https://github.com/dotnet/corefx/commit/118343b2e8cdadaecb90bf8563b19c4a9416cc6e
2016-05-07 00:15:04 -07:00
dotnet-bot 61320ea502 Updating CoreFX dependencies to rc3-24106-00
Commit migrated from https://github.com/dotnet/corefx/commit/22f53438e34b804d30f472ce6482db5e457bfee0
2016-05-06 22:26:49 -07:00
Eric St. John 8d9ac5084b Update Crypto.Algo references from 4.1 to 4.2
Commit migrated from https://github.com/dotnet/corefx/commit/a4cfd53211606c4b056498937e60a7e45de92c17
2016-05-05 18:29:38 -07:00
Eric St. John a813f99b7f Fix restore of Crypt.Algo dependencies from tests
Tests still target DNXCore50 which hasn't been updated to  support
NETStandard1.6.
Recent changes to the algorithms packaged the impl as 1.6.
Until the tests can be updated, import netstandard1.6 explicitly.


Commit migrated from https://github.com/dotnet/corefx/commit/7fdf8c87435b7ca190f2d611b799db88a4f8224a
2016-05-05 18:29:37 -07:00
dotnet-bot eb8b19bb33 Updating CoreFX dependencies to rc3-24105-00
Commit migrated from https://github.com/dotnet/corefx/commit/880e04074fa4918010feb681de16f95f711a5534
2016-05-05 14:18:51 -07:00
David Shulman 087e92da43 Add DefaultCredentials scenario tests
These tests require the client and server to be on a Windows Active Directory domain. These tests are Windows specific. Currently this cannot be done in the CI system. So, these tests are only enabled when an environment variable is set which points to the test server.

There is a separate todo item dotnet/corefx#4989 to provide more automated scripts for setting up the test server. For now, there is a readme file with some details.

These tests will help support fixes for dotnet/corefx#8176 and related bugs.


Commit migrated from https://github.com/dotnet/corefx/commit/4739da8c8d4965fdaf2fc45ae915297208672d15
2016-05-03 15:53:33 -07:00
dotnet-bot a08807e184 Updating CoreFX dependencies to rc3-24102-00
Commit migrated from https://github.com/dotnet/corefx/commit/f9171470a3c4a8261d4cd3945106c7d632a504d9
2016-05-02 23:40:09 +00:00
stephentoub 120b636957 Correctly annotate a stress test with HttpStressEnabled
It's failed a few times in outerloop; we only want it enabled when we're doing a stress test and nothing else is running, as the time it takes can fluctuate if lots of other things are running.


Commit migrated from https://github.com/dotnet/corefx/commit/d80099c00a3f55acc83089d32794e700171c3030
2016-04-30 06:53:02 -04:00
stephentoub 75ad7b6fbd Avoid race condition between queued HttpContent.CopyToAsync and request completion
HttpContentAsyncStream is used by CurlHandler as the request content stream, with writes to it done via HttpContent.CopyToAsync.  We expect the writes to all be asynchronous via WriteAsync. However, it's possible for an override of CopyToAsync to use Write, and if it does, and if we just delegated from Write(...) to WriteAsync(...).GetAwaiter().GetResult(), we would likely deadlock, as the CopyToAsync call is invoked from the single thread responsible for processing libcurl interactions, including supplying the reader that would unblock the writer. To handle this, we have two options: schedule the CopyToAsync to be invoked asynchronously just in case it does a synchronous write, or implement the write to buffer the data.

The former is what was done in https://github.com/dotnet/corefx/pull/4095.  It adds some cost to the expected / common case, but more importantly and worse it can also lead to concurrency problems and spurious exceptions, as for example if the request is faulted/canceled between the time that a task to invoke CopyToAsync is scheduled and the time that it actually executes, we could be invoking CopyToAsync on a disposed HttpContent; worse, we could
end up invoking CopyToAsync while it's being disposed, which could lead to arbitrary state corruption, and which means we can't guard against this with checks to see if the task has already completed.  The only way to fully guard against that is via a lock, but such a lock would itself lead to deadlocks, as the reader that would unblock the writer would have to take the same lock.

In comparison, buffering has the downside of taking up more and arbitrary amounts of memory to store all of the input.  But, we expect synchronous Writes to be rare, and code shouldn't be doing it anyway; if it does, the fix should really be to switch to asynchronous writes. This commit changes from the first approach to the second, using buffering in synchronous Write calls in order to ensure correctness and to optimize for the expected case.


Commit migrated from https://github.com/dotnet/corefx/commit/1ac3f5e62a0d094e7e4277afc43cb1e0c6260b83
2016-04-29 14:15:38 -04:00
David Shulman 366f1290d2 Clean up ResponseStreamTest
Used the MD5 hash verification when verifying correct response body
dowload.

Fixes dotnet/corefx#7885.


Commit migrated from https://github.com/dotnet/corefx/commit/b9859e8b30b781e59e050874f8c9ef096cdcac0c
2016-04-29 10:29:59 -07:00
David Shulman 4c9d153e59 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/1eb395b5a05d6728411b0958a2c9df8b36c39fd5
2016-04-28 16:03:53 -07:00
David Shulman cbb2fa09d4 Fix HttpRequestMessage.Version tests
The current tests validating HTTP request message version were depending on a server behavior that is not guaranteed. In particular, HTTP RFC 7230 states that servers are NOT required to respond back with the same minor version if they support a higher minor version. In fact, the RFC states that servers SHOULD send back the highest minor version they support. So, testing the response version to see if the client sent a particular request version only works for some servers. In particular the 'Http2Servers' used in these tests seemed to echo the minor version of the request.

However, depending on network configuration, intermediate proxies can change the HTTP version that ends up getting sent to the destination server. And as a result, we can have unpredictable behavior in these tests.

To fix this, the tests were switched to use a loopback server that has deterministic behavior.


Commit migrated from https://github.com/dotnet/corefx/commit/d1ffcbcc120d3797dadce6196f499a0631e47caf
2016-04-28 10:57:12 -07:00
stephentoub 6e8cc68acf Consolidate loopback server code to LoopbackServer.cs
Also add Date header to responses


Commit migrated from https://github.com/dotnet/corefx/commit/f4804b5f54a9fe60b0dad794936c7b73b47be19f
2016-04-28 08:42:36 -04:00
stephentoub a2977e9fad More HttpClient test fixes and additions
- The GetAsync_ResponseWithSetCookieHeaders_AllCookiesRead test has been failing with some regularity in CI, with strange GatewayTimeout errors.  I don't know why this particular test is so much more susceptible to that, but I've changed the test to use a local loopback server rather than an external site.

- The SendAsync_ReadFromSlowStreamingServer_PartialDataReturned test was relying on timings from the server that might not always be correct, and due to internal differences between curl and WinHttp were very frequently wrong on Unix such that the test was disabled there.  I reimplemented it with a local loopback server, too.

- I've added another mini-stress test, with posts instead of gets.


Commit migrated from https://github.com/dotnet/corefx/commit/9b6a0224c3e404afe3f2c58dfb59e2068391c879
2016-04-27 13:44:35 -04:00
Stephen Toub bd529e5af9 Merge pull request dotnet/corefx#8082 from stephentoub/curlhandler_finalization
Enable finalization of resources in CurlHandler

Commit migrated from https://github.com/dotnet/corefx/commit/f55dbdb64d28ab231401b906c7bb6f411b045d4e
2016-04-26 21:36:15 -04:00
Eric St. John b1119fb4ef Cleanup usage of Linux/OSX
We've standardized on using Unix in most cases where we only cross-
compile once for Unix.  This change cleans up mentions of Linux/OSX when
we aren't actually cross-compiling for those OSes.

The remaining projects that still cross-compile for Linux/OSX are:
  System.Diagnostics.Process
  System.IO.FileSystem.Watcher
  System.Net.NetworkInformation

The System.Net.Security functional tests seem to still have a distinct
difference in functional behavior on OSX so I have also left these
configured to cross-compile for Linux/OSX.


Commit migrated from https://github.com/dotnet/corefx/commit/16ee317fa4e194ff7cf61e923caf103909e391f1
2016-04-26 14:37:21 -07:00
stephentoub b12f72bd7d Add more HttpClient stress tests
Commit migrated from https://github.com/dotnet/corefx/commit/1482013de9fa08e5834d92ce2884c194f93662fb
2016-04-26 10:41:41 -04:00
dotnet-bot 40d3f889c2 Updating CoreFX dependencies to rc3-24026-00
Commit migrated from https://github.com/dotnet/corefx/commit/b2704ed517b846992ffd66806d54ffdf4cb62526
2016-04-26 05:41:52 +00:00
Davis Goodin d8d35cf32b Validate that the results of a restore are exactly what was requested.
Also update buildtools to fix UpdatePackageDependencyVersion and fix dependencies on packages that had a minor version bump.


Commit migrated from https://github.com/dotnet/corefx/commit/11cafd348f9e0606e55ac5210de0d8847926dbfe
2016-04-25 11:42:47 -05:00
stephentoub 016a8bda35 Address PR feedback
Commit migrated from https://github.com/dotnet/corefx/commit/13b80c9fba1d358ad65519984b36b6b0a017c19e
2016-04-23 11:10:35 -04:00
stephentoub 6c4c36cd4d Add several outerloop HttpClient tests
Several "mini-stress" tests that verify HttpClient doesn't completely fall over under some load:
- Use one HttpClient instance to make many requests serially and in parallel
- Use multiple HttpClient instances to make many requests serially and in parallel
- Ensure that HttpResponseMessages can be GCd even if the associated response hasn't been fully drained.  This one fails right now on unix due to an open issue.


Commit migrated from https://github.com/dotnet/corefx/commit/4358712d3db870725a394478702e643018af52bf
2016-04-22 18:22:41 -04:00
Stephen Toub 093d6fe0e8 Merge pull request dotnet/corefx#7947 from stephentoub/cleanup_activeops
* Force CurlHandler active operations to shutdown when handler disposed

If the CurlHandler is disposed of while active operations are in progress, fail them.  This was generally already happening, but not reliably, and not with the right exception type (a cancellation exception).

Commit migrated from https://github.com/dotnet/corefx/commit/77cb6a2cddd973aeea08e0ceccb578603c1c1364
2016-04-22 09:54:52 -04:00
James Ko 47d83351a2 Avoid string.Split allocations in ContentDispositionHeaderValue (dotnet/corefx#7468)
* Avoid string.Split allocations in ContentDispositionHeaderValue
* Add tests for changes in ContentDispositionHeaderValue

Commit migrated from https://github.com/dotnet/corefx/commit/5bb608835c278482259bff96ac86160bc1a519af
2016-04-22 08:02:21 -04:00
stephentoub 65eda03d5a Force CurlHandler active operations to shutdown when handler disposed
If the CurlHandler is disposed of while active operations are in progress, fail them.  This was generally already happening, but not reliably, and not with the right exception type (a cancellation exception).


Commit migrated from https://github.com/dotnet/corefx/commit/f456d9d60dfec1cd7ff53c1ae5652bf1d76bd02c
2016-04-22 07:16:44 -04:00
dotnet-bot facf18bbf5 Updating CoreFX dependencies to rc3-24022-00
Commit migrated from https://github.com/dotnet/corefx/commit/5bfcca66e5c16c3c1585d1087acd2ea522eb17a7
2016-04-22 05:37:54 +00:00
Stephen Toub ab36076fa6 Size CurlHandler's SendTransferState based on content length (dotnet/corefx#7922)
* Size CurlHandler's SendTransferState based on content length

libcurl will never request more than 16K at a time from a request content stream, so our transfer state object allocates a 16K buffer to use the first time data needs to be transferred.  This size can be efficient in limiting the number of operations required in passing data around, but for small posts, it's an unnecessarily large size.  This commit changes the code to inspect the request content length, and if it's known to be less than 16K, that size is used instead.

Commit migrated from https://github.com/dotnet/corefx/commit/3c362496e358a8097538d81cf8aa6f69bb5493cc
2016-04-21 15:32:52 -04:00
Davis Goodin a7bcdba80c Merge pull request dotnet/corefx#7931 from dagood/fix-package-dependencies
Change non-existent package dependencies to actual versions

Commit migrated from https://github.com/dotnet/corefx/commit/06e1f406147f768f83f3607f4f87066ee796eac9
2016-04-21 09:51:35 -05:00
Stephen Toub e51d35ef2d Revert "Updating CoreFX dependencies to rc3-24021-00"
Commit migrated from https://github.com/dotnet/corefx/commit/019f436a0e66a807a7fefcc24095c5e158033bf8
2016-04-21 10:31:37 -04:00
dotnet-bot c7c632b514 Updating CoreFX dependencies to rc3-24021-00
Commit migrated from https://github.com/dotnet/corefx/commit/5cc2c6a3ce0d0a38fb6f8149bbfae16929f3cd00
2016-04-21 05:34:38 +00:00
Eric Eilebrecht 05b00b4f54 Merge pull request dotnet/corefx#7898 from ericeil/TODOcomments
Associate issues with more TODO comments in System.Net

Commit migrated from https://github.com/dotnet/corefx/commit/0f0a4bcc03db4bc709e100b2107d241f826dd1bb
2016-04-20 12:09:17 -07:00
Davis Goodin 5be2da2fc2 Change non-existent package dependencies to actual versions.
Commit migrated from https://github.com/dotnet/corefx/commit/28f021d9f269ea8207ede73d56b3cd99c8e19c96
2016-04-20 14:06:56 -05:00
Eric Eilebrecht 72de5bd512 Reference dotnet/corefx#7885 from TODO comment
Commit migrated from https://github.com/dotnet/corefx/commit/44022e8ff95ea068180a3a9583dc46bc7193f872
2016-04-20 10:05:53 -07:00
Eric Eilebrecht b50c8321c4 Use [TheoryAttribute] instead of manual looping over data.
Commit migrated from https://github.com/dotnet/corefx/commit/b50b076eb73ad53a5a3a84017a8e581ad5a964c8
2016-04-20 10:05:38 -07: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