GZip Dflat不适用于所有系统

时间:2016-04-04 06:04:23

标签: c# httpwebrequest httpwebresponse

这里我在gzip中有这个问题,dflate,我的代码在某个系统中运行但在所有系统中都不起作用。

它压缩数据高达80%,但我遇到的问题是它无法在所有系统中运行。

请帮帮我......

这是我的代码

string Resp = "";
httpWebReq.ServicePoint.UseNagleAlgorithm = false;
httpWebReq.ServicePoint.Expect100Continue = false;
httpWebReq.ServicePoint.ConnectionLimit = 6500000;
httpWebReq.ServicePoint.ConnectionLeaseTimeout = 50000;
httpWebReq.ServicePoint.MaxIdleTime = 500000;
httpWebReq.Connection = "keepalive";
httpWebReq.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
httpWebReq.UnsafeAuthenticatedConnectionSharing = true;
httpWebReq.AuthenticationLevel = System.Net.Security.AuthenticationLevel.None;
httpWebReq.ProtocolVersion = HttpVersion.Version11;
rspn = (HttpWebResponse)httpWebReq.GetResponse();
response = rspn.GetResponseStream();
if (response.ContentEncoding.ToLower().Contains("gzip"))
{
   Resp = new StreamReader(new GZipStream(response,
   CompressionMode.Decompress), Encoding.UTF8).ReadToEnd();
}
else if (response.ContentEncoding.ToLower().Contains("deflate"))
{
    Resp = new StreamReader(new DeflateStream(response,
}
else
{
    Resp = new StreamReader(response, Encoding.UTF8).ReadToEnd();
}

请建议我在所有系统中压缩数据的任何其他想法....

0 个答案:

没有答案