I created a service that allowed users to download all address data from Belgium in CSV format. By default when fetching this data through the HttpClient it would result in having the full blob into memory.
But thanks to the power if IAsyncEnumerable<>
and setting the HttpCompletionOption.ResponseHeadersRead
flag when calling GetAsync()
I could get this done in a very efficient way:
By setting the HttpCompletionOption.ResponseHeadersRead
flag the client would only wait until the headers are received and then continue execution. So I could start processing the results before all data was downloaded.