Description
UPDATE (3/5): The PR is up at 👉 #34894. Let's take up the discussion there.
Description
- Issue: Make modern http streaming apis easily consumable in WebAssembly runtime#112442
- PR: [browser] [wasm] Make response streaming opt-out runtime#111680
@pavelsavara @campersau ... In addition to covering the opt-out feature for 10.0, it looks like the current guidance is incomplete. Please correct me if I'm wrong in the following remarks.
Existing remarks and opt-in behavior <10.0
Our only existing remark on this subject is ...
The HTTP response is typically buffered to enable support for synchronous reads on the response content. To enable support for response streaming, use the <xref:Microsoft.AspNetCore.Components.WebAssembly.Http
.WebAssemblyHttpRequestMessageExtensions.SetBrowserResponseStreamingEnabled%2A> extension method on the request.
It looks now like that's incomplete because of ...
In order to be able to use
WebAssemblyEnableStreamingResponse
/SetBrowserResponseStreamingEnabled
option on large files, the user should also setHttpCompletionOption.ResponseHeadersRead
so that the content would not be cached in memory. The default isResponseContentRead
which makesHttpClient
to "... complete after reading the entire response including the content."
Cross-ref: dotnet/runtime#60287 (comment)
I wasn't aware of additional remarks on that, such as ...
I guess it would be great to also mention the
HttpCompletionOption.ResponseHeadersRead
in the docs as well.
Cross-ref: dotnet/runtime#60339 (comment)
I plan to add it to the existing coverage in a paragraph with the following example, which dovetails with our current example code ...
- var response = await Http.SendAsync(requestMessage);
+ var response = await Http.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead);
New API >=10.0
First, what Preview release is this landing for?
As of dotnet/runtime#111680 for 10.0, response streaming will be enabled by default with the following API to opt-out ...
request.Options.Set(new HttpRequestOptionsKey<bool>("WebAssemblyEnableStreamingResponse"), false);
Page URL
https://learn.microsoft.com/en-us/aspnet/core/blazor/call-web-api?view=aspnetcore-9.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/call-web-api.md
Document ID
c7e59a08-1c60-32c2-75fd-33cb77ff7a5d
Article author
Metadata
- ID: 8b5e2e10-ff7b-2b9f-84da-f16028ae2c53
- PlatformId: 32bfc271-12a7-7ce3-dcec-43ac2e8c68d7
- Service: aspnet-core
- Sub-service: blazor
Metadata
Metadata
Assignees
Labels
Type
Projects
Status