[Breaking change]: [browser] streaming HTTP response is on by deafult #45644
Labels
breaking-change
Indicates a .NET Core breaking change
🏁 Release: .NET 10
Work items for the .NET 10 release
📌 seQUESTered
Identifies that an issue has been imported into Quest.
Description
This breaking change introduces default support for streaming HTTP responses in browser HTTP clients, which previously required opt-in. This enhancement leverages the capabilities of modern evergreen browsers to improve memory consumption and responsiveness, particularly for large data requests and scenarios like streaming AI chat responses. However, developers should be aware that the
response.Content.ReadAsStreamAsync()
method will now return aBrowserHttpReadStream
instead of aMemoryStream
, which does not support synchronous operations. This change may impact existing code that relies on synchronous stream operations.See dotnet/runtime#111680 for details
Version
.NET 10 Preview 3
Previous behavior
In the Browser/Wasm/Blazor, previously the C# HTTP client buffered the whole response and the
HttpContent
contained fullMemoryStream
by default. Unless you opted in viaWebAssemblyEnableStreamingResponse
HttpRequestOption which enabled the streaming response, typical on other operating systems.New behavior
The
WebAssemblyEnableStreamingResponse
is now opt-out instead of opt-in. TheHttpContent
is notMemoryStream
by default.Type of breaking change
Reason for change
To aid use-cases around streaming
GetFromJsonAsAsyncEnumerable
which work by default on other OSes.Recommended action
If you need to disable it globally, you can use
set env variable
DOTNET_WASM_ENABLE_STREAMING_RESPONSE
We plan to make the
<WasmEnableStreamingResponse>false</WasmEnableStreamingResponse>
in your project file for in future previews of Net 10. See dotnet/runtime#97449To disable it for individual request, you can use existing
request.Options.Set(new HttpRequestOptionsKey<bool>("WebAssemblyEnableStreamingResponse"), false);
or
request.SetBrowserResponseStreamingEnabled(false)
extension in Blazor projectFeature area
Networking
Affected APIs
No response
Associated WorkItem - 418815
The text was updated successfully, but these errors were encountered: