GZIP output stream

本文关键字:stream output GZIP | 更新日期: 2023-09-27 18:01:58

我正在尝试GZIP一些XML得到流通过HTTP(不是web服务)

if (ZipOutput)
{
    output = new GZipStream(Context.Response.OutputStream, CompressionMode.Compress);
    Context.Response.AppendHeader("Content-Encoding", "gzip");
}
else
{
    output = Context.Response.OutputStream;
}
EscapeXMLTextWriter xmlWriter = new EscapeXMLTextWriter(output, new UTF8Encoding())
{
    Formatting = Formatting.Indented
};

ZipOutputtrue,但响应似乎没有被压缩。有什么建议吗,替代技术?

我知道我可以使用SharpZipLib,但想在框架中使用GZipStream类。

GZIP output stream

在我看来,你的代码应该可以工作——也许可以用调试器来检查代码是否真的像你想象的那样被调用。

在- http://www.west-wind.com/weblog/posts/2007/Feb/05/More-on-GZip-compression-with-ASPNET-Content

上有一篇很好的文章(包括一种替代技术)

我想我找到了这个问题-原来是办公室防火墙在出站请求上剥离了Accept-Encoding头。