Commit Graph
217 Commits
Author SHA1 Message Date
Hemanth Kapila 3fd7c5ee4f Support for http delete and other methods for CurlHandler
Update CurlHandler to allow sending Http 'delete', 'options' and etc
Add two test cases for delete
Add two test cases for options

Support for other Http methods

Added tests for options as well


Commit migrated from https://github.com/dotnet/corefx/commit/20819227e708d42db9c3c4f8b7c0fd13180da777
2015-10-27 21:15:04 +05:30
Hemanth Kapila 9bdfc50043 Test case for default state of HttpClientHandler.CookieContainer
Adding a new test case that verifies that httpClient does not send any cookie unless set


Commit migrated from https://github.com/dotnet/corefx/commit/7550e8bdd3af85f322fd309f412f919a6cd4f150
2015-10-22 20:22:19 +05:30
David Shulman e45cc6afdf Add test to verify default values for HttpClientHandler
Ported this test to GitHub.

Note that the change in default values between Desktop and CoreFx for two
of the properties is an "intentional, improving, change".


Commit migrated from https://github.com/dotnet/corefx/commit/7aa4a1f71640351230943fa06f51602cb2c07cb3
2015-10-08 15:35:10 -07:00
David Shulman b7b2027a1e Add more HTTP tests
Ported some missing tests to GitHub. Cleaned up some of the existing
tests.


Commit migrated from https://github.com/dotnet/corefx/commit/870810a3a50b41acc088a907dd7a5ea88a214ec8
2015-10-08 14:05:35 -07:00
Hemanth Kapila 4f26738d30 CURL Handler redirect fixes
This commit fixes the following issues  in CurlHandler w.r.t following URI redirection

* Ensure that the credentials are nullified at the right place. We should not set username and/or password to null unnecessarily. libcurl differentiates between unset UserNames/Passwords and null user names/passwords

* Ensure that libcurl follows only HTTPS uri if the original request was for a HTTPS URL.

* Ensure that libcurl follows only a HTTPS or a HTTP uri if the original request was for a HTTP URL.

* Ensure redirect results in a proper response code

* For all requests, limiting protocols to http and https


Commit migrated from https://github.com/dotnet/corefx/commit/7c59e04ce8b26887c386fc3045882196a3142b36
2015-10-01 19:34:28 +05:30
David Shulman a6002ce802 Add more HTTP tests
* Add more tests ported from the internal ToF tests.
* Cleanup existing tests to be consistent in style and format as it has
drifted due to many different people working on the tests.
* Disposing the HttpClient object will dispose the handler as well so we
don't need multiple 'using' statements unless we are explicitly testing
dispose ordering semantics.


Commit migrated from https://github.com/dotnet/corefx/commit/ad55c1d5685afc4009cb2481fcc7c5e4f4a551f8
2015-09-30 20:11:07 -07: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
stephentoub 791179fdf2 Add MaxRequestContentBufferSize tests to lock in behavior
Commit migrated from https://github.com/dotnet/corefx/commit/e25c5020fd9e327dfdb7baffb9d772967b28abc9
2015-09-19 20:29:06 -04:00
stephentoub 54c0b5401d Add tests for different request streams
Commit migrated from https://github.com/dotnet/corefx/commit/f9d1b3c47d4ff46afaa44fdb0eede63712e92164
2015-09-09 10:00:25 -07:00
Hemanth Kapila 5e333c2d1b Fix for dotnet/corefx#3124. CurlHandler sets invalid content-type for POST requests
libcurl defaults to a Content-Type:application/x-www-form-urlencoded for
Post operations. This default behavior is inconsistent with dotnet API.
Current PR fixes this issue by overriding the default value.
Also included is the test that was mentioned in dotnet/corefx#3124


Commit migrated from https://github.com/dotnet/corefx/commit/594ee48d91fbe827fb3e3cca05ef1cba8466e152
2015-09-09 11:56:39 +05:30
stephentoub d25820bc15 Avoid blocking CurlHandler write callback
When receiving the body of an HTTP response, libcurl provides the data
received via a callback that's invoked synchronously from the thread
pumping libcurl's processing.  This callback can't return until it's
handed off all of the available data, and thus the current implementation
of CurlHandler blocks that thread until a reader has consumed the data.
This is both expensive and dangerous.  It's expensive because we end up
blocking a thread until some reader comes along, and it's dangerous
because this can easily lead to deadlock.  A libcurl multi handle may be
used by only one thread at a time, which means that if the handle is being
used by a thread while blocked on the write callback, no other thread can
access the multi handle, which means no other callbacks for other
concurrent requests can be invoked.  If multiple operations were queued,
and then the data for them arrived in an order that didn't exactly match
the order of readers consuming the data, deadlock would ensue.

This change makes it so that we no longer block the callback, taking
advantage of a pausing mechanism libcurl provides that allows one to pause
a connection until it's needed.

I rewrote the CurlResponseStream to manage this.  Now when the callback
has data to write, it attempts to transfer it to the stream.  If there's a
reader already waiting for the data (represented by a task stored on the
stream), the callback simply transfers its data to the reader.  If the
callback has too much data than would fit in the reader, the remaining
data is buffered on the stream.  If instead the callback finds that either
there isn't a waiting task or that there's already some remaining data
buffered from a previous callback, it instead pauses the connection, such
that no more callbacks will be invoked until we unpause.  From the reader
side, a reader who tries to read data from the stream can pull data from
the remaining buffer if there is any, or can register a task with the
stream that will be filled with data at some point when callback has data
available.

As part of debugging some issues with this change, I added a verbose
tracing mechanism that's enabled by compiling the library with the
CURLHANDLER_VERBOSE constant (the same that we use for enabling libcurl's
verbose diagnostic output).  I left the tracing in as I found it valuable
in diagnosing issues with the library, but we can remove it later if
desired.

I also added a test that deadlocks before the change and that completes
successfully after.


Commit migrated from https://github.com/dotnet/corefx/commit/308efaba2833e5e146319f74a2281e12ef3e5519
2015-09-07 12:21:45 -04:00
Shruti Garg 1d9af3015d Fixing Review comments Post/Put Testcases
Commit migrated from https://github.com/dotnet/corefx/commit/853100ed6f051b3af9eeee8b55e16a60a4703d1e
2015-09-07 12:40:27 +05:30
Shruti Garg ad0bf80977 Enabling Testcases for POST/PUT methods
Commit migrated from https://github.com/dotnet/corefx/commit/20b14c9e9948310a6f0eb507066411d5e7eab5ce
2015-09-04 15:49:23 +05:30
Hemanth Kapila 1b11b28b8f Introducing tests for HttpClientHandler
This checkin tests the client handler in following scenarios:
* Http and Https calls
* Authentication
* Redirection
* Redirection + Authentication
* custom headers
* cookies


Commit migrated from https://github.com/dotnet/corefx/commit/5040201f90c169d6033532170547f111a28bfb81
2015-09-01 16:42:27 -04:00
Guillermo Rangel ff81931a13 Fixing CancellationToken not propagating properly and adding some Tests to verify it.
Addressing Feedback in GitHub

Renaming TestHandler to SendAsyncWinHttpMockHandler and adding missing spaces.

Added missing line in json file to use System.Runtime.InteropServices.RuntimeInformation.


Commit migrated from https://github.com/dotnet/corefx/commit/e76774df88b497107e8289fce314ea149abc7811
2015-08-11 13:58:39 -07:00
dotnet-bot 82d561b50e Skip functional network tests on platforms where System.Net.Http library is not ported.
Commit migrated from https://github.com/dotnet/corefx/commit/c4814af0613cecad5bbf71fec1697600b27d6efc
2015-07-16 13:29:30 -07:00
dotnet-bot 6f05324ca8 Refactor Http tests for multiple test projects
This change sets up the layout for having multiple test projects for Http.  It follows the current guidlines as well as working within the BUILDTOOLS requirements of having ".Tests.csproj" for the names of the projects.


Commit migrated from https://github.com/dotnet/corefx/commit/e7b68608db14327ec55fc90c0f5aee3ed72fab36
2015-07-16 11:32:48 -07:00