且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

阅读"分块"响应与HttpWebResponse

更新时间:2021-10-10 06:06:34

还没有尝试过这一点的,分块的反应,但会像这样的工作?

Haven't tried it this with a "chunked" response but would something like this work?

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);