Read from infinite online stream using Windows.Web.Http.HttpClient.
If you have an infinite Transfer-Encoding: Chunked HTTP response, you can read it this way:
private async void Foo()
{
// Example URI.
Uri uri = new Uri("http://localhost/?chunked=1&length=10000000000&delay=500");
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(
uri,
HttpCompletionOption.ResponseHeadersRead);
IInputStream inputStream = await response.Content.ReadAsInputStreamAsync();
ulong totalBytesRead = 0;
IBuffer buffer = new Windows.Storage.Streams.Buffer(1000000);
do
{
buffer = await inputStream.ReadAsync(
buffer,
buffer.Capacity,
InputStreamOptions.Partial);
// ...
totalBytesRead += buffer.Length;
Debug.WriteLine(buffer.Length + " " + totalBytesRead);
} while (buffer.Length > 0);
Debug.WriteLine(totalBytesRead);
}