HttpCompletionOption.ResponseHeadersRead is a value of the HttpCompletionOption enumeration that specifies how an HTTP request should be completed. When using this option in a Refit request, the client retrieves the response headers immediately as soon as they are available and returns the rest of the response as an ongoing stream.
To use HttpCompletionOption.ResponseHeadersRead in a Refit request, you should follow the below steps:
[Get("/api/example")]
[HttpCompletionOption(HttpCompletionOption.ResponseHeadersRead)]
Task<HttpResponseMessage> GetExample();
var response = await restService.GetExample();
var stream = await response.Content.ReadAsStreamAsync();
Using this approach, the application can process large responses efficiently, without waiting for the entire response to be downloaded before starting to process it.
Asked: 2022-06-28 11:00:00 +0000
Seen: 7 times
Last updated: Feb 14 '23