.NET Stream.Read() semantics leave it to the implementation to decide how much data to return given a buffer of size N:
https://msdn.microsoft.com/en-us/library/system.io.stream.read(v=vs.110).aspx
"An implementation is free to return fewer bytes than requested even if the end of the stream has not been reached."
The behavior of System.Net HTTP APIs (i.e. .NET Framework) are such that stream reads are able to return as soon as data is available. They don't wait until the provided buffer is full. The current WinHttpHandler was not behaving that way because it didn't call WinHttpQueryDataAvailable before calling WinHttpReadData. WinHttpQueryDataAvailable would indicate how many bytes can be read immediately.
This fix changes the WinHttpResponseStream.Read* methods to use WinHttpQueryDataAvailable before calling WinHttpReadData.
Added both WinHttpHandler unit tests (helps with simulating/testing network errors) and HttpClientHandler functional tests (which will test x-plat).
Fixesdotnet/corefx#1825
Commit migrated from https://github.com/dotnet/corefx/commit/5386014a6b74a8d38010b244f9e9ced96df53b69
A change was made to DNX to no longer restore project.jsons
that are in nested folders. This caused my batch update to miss
a number of tests and reference assembly projects.
This fixes the stale lock files, but restore is still broken.
[tfs-changeset: 1540448]
Commit migrated from https://github.com/dotnet/corefx/commit/3622cccc1b22fa1947a72d5126b59864e9d2fd0d
We need a new DNX to understand the latest packages.
We also need to move all "dotnet" projects to use dotnetX.X (generations)
now that the packages no longer have "dotnet" assets.
The new version of DNX dropped support for the aspnetcore
so I needed to update a few projects/packages that depended
on old package versions that had this moniker.
[tfs-changeset: 1540388]
Commit migrated from https://github.com/dotnet/corefx/commit/38f8d7a3ca1ee819c2b8eabb1c07ee4e99683c97
This is a large PR and addresses work item dotnet/corefx#3000. I apologize for not being able to structure it in a series of smaller commits.
The bulk of this PR is switching WinHttpHandler to use the async pattern of calling WinHTTP APIs. This involved a significant restructuring of the code. As part of that, I split up the large WinHttpHandler class into multiple, smaller, helper classes.
While the intent of using async WinHTTP calls is better performance and cancel-ability, this PR has not been fully optimized yet. Due to the schedule of RC1 code complete next week, it's important that this PR get in and get mileage on it in the next few weeks.
There are several TODO items that will be done in later PR's. There is still work being tracked in dotnet/corefx#2165 for various follow-up items. For example, re-conciling the best SafeHandle pattern to use for WinHTTP between WebSockets.Client and WinHttpHandler.
I'm currently using a simple Debug.WriteLine for verbose debug logging which can be turned on/off via environment variable. I plan to switch this to System.Net ETW trace loggers in the next commit and/or PR. But the logging has proved very useful in diagnosing issues.
Please provide feedback. Depending on the feedback, some of it will be marked as follow-up items for future PRs.
Commit migrated from https://github.com/dotnet/corefx/commit/d8e5371a5d0f9f4bb3aa85127cb78adf89dde1fb
* 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
`build.cmd /p:LockDependencies=true` was the start of this change, but some errors with xunit build numbers led to all xunit upgrades being reset back to what they had in master.
project.json changes:
* System.Net.Security\src Switch off of explicit beta versioning, use the same baseline as everyone else. The S.S.C.Algorithms explicit upgrade is no longer required.
* System.Net.Requests\tests didn't build. Looking at the project.lock.json change, it appeared that a System.Net.Http reference was lost, restored it.
* System.Net.Http\tests didn't build. Looking at the project.lock.json change, it appeared that a System.IO.FileSystem reference was lost, restored it.
* System.Net.WebSockets.Client\src didn't build. Looking at the project.lock.json change, it appeared that a System.Collections (4.0.10) reference was lost, restored it.
* System.Diagnostics.TextWriterTraceListener\tests needed the runtime reference to load the correct System.Diagnostics.TraceSource binary.
Commit migrated from https://github.com/dotnet/corefx/commit/cec3a0f2db542bfa9d9c56bf988d966eacc35ad9
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
The corefx build used an older beta5 version of DNX which hardcoded the path to bash in dnu, breaking the build on FreeBSD.
Updating DNX to the latest "stable" beta7 release fixes this.
After updating I noticed a few test projects didn't build anymore as they were missing some dependencies in project.json, added those.
Fixesdotnet/corefx#3173
Commit migrated from https://github.com/dotnet/corefx/commit/6df77fdbb6cf8e0d35a3074bb325f7810085daa3
The stable versioned packages use an older codebase currently than the latest pre-release.
That codebase is still using SecureString in System.Private.Networking, but the dependency
was omitted since crypto is still pre-release but networking had to be marked stable for UWP.
This missing dependency was causing tests to fail.
Rather than just list the dependency I am moving these tests back to pre-release packages
for the System.Net contracts, since System.Net packages are under active development
it is better to have the tests running against latest than the stable bits.
Once we have newer versions published we'll update these tests to use those.
Commit migrated from https://github.com/dotnet/corefx/commit/5d9f9d4c6ea450366c7b70af6e6006a401284d14
This change modifies the build to consume the stable version where available.
This disables building the dowlevel packages since we shipped them once as stable and we're done.
From here on out, we'll only build the latest version (except for a servicing event, which would
be handled by syncing to a hash).
I can't rev the package versions in the normal way yet (by modifying the assembly version of the contents)
because that turned out to be too big of a problem to tackle in this change. Instead I added a
parameter to the task that calculates package versions to do the rev for anything that was
stable, but only when building the package itself, not when calculating the dependencies.
This has the downside of not permitting a dependency on a incremented pre-release version if we've
shipped a stable version, but that is a small point in time problem until I can rev the assembly
versions.
[tfs-changeset: 1508664]
Commit migrated from https://github.com/dotnet/corefx/commit/ee1ec2891c7c65b46fa9dfb078636be503bb2a60
This change sets up the layout for having multiple test projects for
WinHttpHandler. It follows the current guidlines as well as working
within the BUILDTOOLS requirements of having ".Tests.csproj" for the
names of the projects.
Also, fixed up some cross-platform definitions in the solutions files
for Http and WinHttpHandler.
After this PR is done, we will be migrating a large set of http
functional tests to GitHub
Commit migrated from https://github.com/dotnet/corefx/commit/42d81c41175ab8832032a2a387b8dc58365604a9