Windows PCL HttpClient

问题描述:

我正在使用System.Net.HttpClient从服务器读取流。我遇到的问题是流被阻塞,直到整个响应都在内存中。我想开始处理数据来自网络的响应。解析之前等待整个响应速度太慢。Windows PCL HttpClient

HttpClient client = new HttpClient(); 
... 
await client.GetStreamAsync(); 
/* another way I tried */ 
HttpResponseMessage response = await clientGetAsync(); 
if(response.StatusCode == HttpStatusCode.OK) { 
    await response.Content 
} 

await response.Content.ReadAsStreamAsync(); 

有没有一种方法,它没有要与HttpClient的,以获得流,因为它是使用Windows便携类库网络来吗?

必须使用SendAsyncHttpCompletionOption.ResponseHeadersRead以防止HttpClient缓冲响应流。使用此选项后,ReadAsStreamAsync将返回实际网络流而不是MemoryStream的包装。