【发布时间】:2015-11-18 12:32:55
【问题描述】:
我在读取流响应时遇到问题,因为我无法读取结束响应。
这是来自服务器的响应:
Server : "Apache-Coyote/1.1"
Transfer-Encoding : "chunked"
Content-Type: "multipart/mixed; boundary=F34D3847AEDEB14FF5967BF7426EECF6"
我尝试阅读此回复:
var response = (HttpWebResponse)await httpWebRequest.GetResponseAsync();
using(var read = new StreamReader(response.GetResponseStream())
{
var result = await read.ReadToEndAsync();
}
还有这个方法:
StringBuilder sb = new StringBuilder();
Byte[] buf = new byte[8192];
Stream resStream = response.GetResponseStream();
string tmpString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if(count != 0)
{
tmpString = Encoding.ASCII.GetString(buf, 0, count);
sb.Append(tmpString);
}
}while (count > 0);
错误信息:
Exception from HRESULT: 0x80072EE4
I/O error occurred.
Exception thrown: 'System.IO.IOException' in mscorlib.ni.dll
Exception thrown: 'System.IO.IOException' in mscorlib.ni.dll
不幸的是,它不起作用,只得到响应的片段。谢谢你的帮助
【问题讨论】:
标签: c# windows uwp httpwebresponse chunked