【问题标题】:OWIN GZip Compression prevented by User-Agent用户代理阻止了 OWIN GZip 压缩
【发布时间】:2016-05-25 16:15:38
【问题描述】:

我有一个提供静态文件的 OWIN/Katana 自托管 Web 服务器。我正在尝试压缩响应并遇到一个问题,即 IE 或 Chrome 添加的用户代理阻止了这种情况的发生。

在 Fiddler 中,使用标题 Accept-Encoding: gzip, deflate, sdch 我正确得到 Content-Encoding: deflate

如果我添加:

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36

User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko

然后响应不再有内容编码。

我尝试过使用自定义中间件和 Owin.Compression https://github.com/Thorium/Owin.Compression

               appBuilder.UseCompressionModule();
               //appBuilder.Use<GZipMiddleware>();

               appBuilder.UseStaticFiles(
                   new StaticFileOptions
                   {
                       RequestPath = new PathString(ApplicationPath),
                       FileSystem = new PhysicalFileSystem("app")
                   });

【问题讨论】:

    标签: c# compression gzip owin katana


    【解决方案1】:

    解决了这个问题。

    我的防病毒软件 (ESET) 正在解压缩响应并删除标题以扫描内容。由于这是一台锁定的工作机器,我无法调整设置,因此我能够确认使用虚拟机并继续测试。

    【讨论】:

      猜你喜欢
      • 2011-06-02
      • 2015-07-14
      • 2019-05-02
      • 1970-01-01
      • 2012-08-14
      • 2013-12-29
      • 1970-01-01
      • 2010-10-23
      相关资源
      最近更新 更多