3

我正在尝试 GZIP 一些通过 HTTP 流式传输的 XML(不是 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在框架中使用该类。

4

2 回答 2

3

在我看来,您的代码应该可以工作——也许可以使用调试器逐步检查代码是否真的按照您的想法被调用。

在http://www.west-wind.com/weblog/posts/2007/Feb/05/More-on-GZip-compression-with-ASPNET-Content上有一篇很好的文章(包括一种替代技术)

于 2011-07-14T08:16:10.867 回答
2

我想出了这个问题 - 结果是办公室防火墙正在剥离出站请求的 Accept-Encoding 标头。

于 2011-07-19T09:17:06.773 回答