码迷,mamicode.com
首页 > Web开发 > 详细

HttpWebResponse对gzip格式返回结果的处理

时间:2014-11-30 23:08:52      阅读:298      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   sp   on   div   log   

  HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); 

HttpWebResponse webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse();


            Stream streamReceive = webResponse.GetResponseStream();

  if (webResponse.ContentEncoding.ToLower().Contains("gzip"))
                {
                    //gzip格式
                    streamReceive = new GZipStream(streamReceive, CompressionMode.Decompress);
                }

 using (System.IO.StreamReader sr = new System.IO.StreamReader(streamReceive, encoding))
                {
                    responseData = sr.ReadToEnd();
                }

 

HttpWebResponse对gzip格式返回结果的处理

标签:style   blog   http   io   color   sp   on   div   log   

原文地址:http://www.cnblogs.com/liuhaitao/p/4133861.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!