Skip to content

BrowserHttpMessageHandler reads body content to end #5586

@csnewman

Description

@csnewman

Inside "Blazor/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Services/Http.ts", the response data is handled via " responseData = await response.arrayBuffer();", which reads the entire response stream to the end, and then returns the data, however this is the incorrect behaviour.

HttpMessageHandler's should not buffer the response as this is handled within the HttpClient.

This means that method such as "_httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, CancellationToken.None);", are not handled correctly as the ResponseHeadersRead flag is not respected, due to the content body being read to the end.

We would need to wrap the ReadableStream from the JS side to the c# side as the HttpContent in the ReceiveResponse in BrowserHttpMessageHandler.

Is there any chance of getting this fixed? As I've managed to get the c# signalr client working with long polling, but can't get the "ServerSentEventsTransport" to work until this is fixed, as otherwise the client timeouts trying to read the content body to the end, when it shouldn't as the ResponseHeadersRead is passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing one

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions