EasyHTTP - Streamresponse

你也可以把响应体放在stream

1
2
3
4
5
6
7
8
9
10
11
12
13
var httpClient = new HttpClient();
httpClient.StreamResponse = true;
httpClient.Get("http://localhost:16000/hello");
using (var stream = httpClient.Response.ResponseStream)
{
int count;
int total = 0;
var buffer = new byte[8192];
while ((count = stream.Read(buffer, 0, buffer.Length)) > 0)
{
total += count;
}
}

StremResponse设置为true时,RawText属性将为空。

1
httpClient.Response.RawText