diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs index b4450bb425641..c187e80d15f90 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/BrowserHttpHandler.cs @@ -220,7 +220,6 @@ protected internal override async Task SendAsync(HttpReques requestObject.SetObjectProperty("headers", jsHeaders); } - WasmHttpReadStream? wasmHttpReadStream = null; JSObject abortController = new HostObject("AbortController"); @@ -375,6 +374,12 @@ public void Dispose() } } + private sealed class BrowserUnseekableStream : MemoryStream + { + public BrowserUnseekableStream (byte [] data) : base (data, writable: false) { } + public override bool CanSeek => false; + } + private sealed class BrowserHttpContent : HttpContent { private byte[]? _data; @@ -407,7 +412,7 @@ private async Task GetResponseData() protected override async Task CreateContentReadStreamAsync() { byte[] data = await GetResponseData().ConfigureAwait(continueOnCapturedContext: true); - return new MemoryStream(data, writable: false); + return new BrowserUnseekableStream (data); } protected override Task SerializeToStreamAsync(Stream stream, TransportContext? context) =>