C# gzip 解压 问题
最近公司 要做一个接口,不过对方放回的 是通过gzip 加压过的,现在我只能得到乱码的字符串,请问如果讲 gzip 解压 成 原来的 字符串
[解决办法]
http://stackoverflow.com/questions/1581694/gzipstream-and-decompression
[解决办法]
if (HttpWResp.ContentEncoding.ToLower().Contains("gzip"))
{
using (GZipStream stream = new GZipStream(HttpWResp.GetResponseStream(), CompressionMode.Decompress))
{
using (reader = new StreamReader(stream, System.Text.Encoding.GetEncoding("gb2312")))
{
result = reader.ReadToEnd();
//return HttpUtility.HtmlDecode(result);
}
}
}
else
{
Stream myStream = HttpWResp.GetResponseStream();
using (reader = new StreamReader(myStream, System.Text.Encoding.GetEncoding("gb2312")))
{
result = reader.ReadToEnd();
}
}