'Is there something like a HttpCompletionOption in RestSharp?

I'd like to do something like this in Blazor:

HttpClient httpClient = new HttpClient
{
    Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite) };
    var request = await httpClient.GetAsync("https://this.is.my.url", HttpCompletionOption.ResponseHeadersRead);
    var stream = await request.Content.ReadAsStreamAsync();
    var bufferedStream = new BufferedStream(stream);
}

but Blazor ignores the HttpCompletionOption.ResponseHeadersRead.

For this reason, I've searched for an alternative to the HttpClient class.

RestSharp could be the solution to my problem, but I can't find an option to tell the RestClient that the operations should be considered completed as soon as a response is available and not after reading the entire response message including the content.

Is there something like the HttpCompletionOption.ResponseHeadersRead in RestSharp?



Solution 1:[1]

You could try request.SetBrowserResponseStreamingEnabled(true) (https://docs.microsoft.com/de-de/dotnet/api/microsoft.aspnetcore.components.webassembly.http.webassemblyhttprequestmessageextensions.setbrowserresponsestreamingenabled?view=aspnetcore-6.0)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Apollo3zehn