Fix SocketsHttpHandler streams to do sync I/O in sync methods (dotnet/corefx#36946)
authorStephen Toub <stoub@microsoft.com>
Thu, 18 Apr 2019 04:01:04 +0000 (00:01 -0400)
committerGitHub <noreply@github.com>
Thu, 18 Apr 2019 04:01:04 +0000 (00:01 -0400)
commit59dfed72f2eba1f52b4f0f9712c5e1138d74f3f1
tree671e94645f433417c9c1edc1091cbe1bb8ee5db1
parentc28ecfa2bf707c7b8ce64efce2c61f528fcd8315
Fix SocketsHttpHandler streams to do sync I/O in sync methods (dotnet/corefx#36946)

* Fix SocketsHttpHandler response streams to do sync I/O in sync methods

SocketsHttpHandler hands back response Streams for reading response body content.  While we encourage developers to use the async Stream APIs, Stream does expose synchronous APIs, yet the current implementations are just wrapping the async ones and doing sync-over-async.

This fixes the response stream synchronous APIs to be sync down to the underlying networking stream.

It also fixes a couple other minor issues, e.g. Flush{Async} on read-only stream should be nops rather than throwing, we should include an error message about a stream being read-only when trying to write to it, etc.

* Address PR feedback

Commit migrated from https://github.com/dotnet/corefx/commit/315fd00cb2465390900209919cdb2bf6bc44ae0e
13 files changed:
src/libraries/System.Net.Http/src/System.Net.Http.csproj
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ChunkedEncodingReadStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionCloseReadStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ContentLengthReadStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/EmptyReadStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Stream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpBaseStream.cs [moved from src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/BaseAsyncStream.cs with 75% similarity]
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpContentReadStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpContentStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpContentWriteStream.cs
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/RawConnectionStream.cs
src/libraries/System.Net.Http/tests/FunctionalTests/ResponseStreamTest.cs