Skip to content

Commit 0d58c82

Browse files
committed
Revert part of the previous commit
- `ReadAsStreamAsync()` introduces unwanted behaviours - returned `Stream` cannot be read multiple times and is not recreated on next `ReadAsStreamAsync` call - method buffers the `HttpContent`, invalidating the intent of `unBuffered`
1 parent da6d49a commit 0d58c82

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/System.Net.Http.Formatting.Test/HttpMessageContentTests.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ private static async Task<string> ReadContentAsync(HttpContent content, bool unB
5050
{
5151
if (unBuffered)
5252
{
53-
using var reader = new StreamReader(await content.ReadAsStreamAsync());
53+
var stream = new MemoryStream();
54+
await content.CopyToAsync(stream);
55+
stream.Position = 0L;
56+
57+
// StreamReader will dispose of the Stream.
58+
using var reader = new StreamReader(stream);
5459

5560
return await reader.ReadToEndAsync();
5661
}

0 commit comments

Comments
 (0)