HttpWebResponse对gzip格式返回结果的处理
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(); }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。