- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下(简化的)文件夹/文件结构:
/.htaccess
/test.php
/api/web/index.php
<IfModule mod_deflate.c>
<IfModule mod_filter.c>
SetInputFilter DEFLATE
</IfModule>
</IfModule>
POST /test.php HTTP/1.1
Host: 192.168.1.248
Authorization: Bearer ed717c077e4bf81201196011adb457731b24e19d
Content-Type: application/json
Content-Encoding: gzip
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api/(.*) api/web/index.php/$1 [NC,L]
/test.php
,一切都按预期工作, body 放气了,我可以正确访问解压缩的内容。
/api/
或
/api/v1/project
),
index.php
脚本没有解压正文。
RewriteRule
有关忽略
SetInputFilter
的指令指令,但是,我怎样才能避免这种情况呢?
SetInputFilter
直接在 .htaccess 中指令而不解决问题(可能是它不在正确的位置?)。
最佳答案
确实,有问题。我做深入调查的第一件事是记录相关模块的痕迹( rewrite
、 filter
和 deflate
)。
mod_rewrite 日志 还可以,那里没有什么可疑的。为了确保一切正常,我查看了它的最新版本 source code .再一次,没有关于编码/解码的可疑之处(更一般地说,也没有 http 请求/响应 header )。
所以我开始认为问题可能来自 filter
或 deflate
模块,即使它也可能来自其他地方。为了确认/确认我的想法,我查看了这些模块日志。很快,我就看到了两个测试用例之间的区别:有或没有 mod_rewrite
涉及。
不涉及 mod_rewrite
mod_deflate.c(1421): [client 127.0.0.1:53000] AH01393: Zlib: Inflated 35 to 41 : URL /test.php
mod_filter.c(188): [client 127.0.0.1:53000] Content-Type condition for 'deflate' matched
mod_filter.c(188): [client 127.0.0.1:53002] Content-Type condition for 'deflate' matched
mod_deflate
是问题所在。我怀疑它的行为是
之后 正确的时刻。这就是为什么你在这种情况下看不到它的原因。
mod_deflate too late
,偶然给了我
what I was searching for .这张票叫
mod_deflate adjusts the headers "too late" , 声明如下:
When mod_deflate is used to inflate, it must adjust the request headers (e.g. it needs to remove the "Content-Length" header and adjust the "Content-Encoding" header).
Currently mod_deflate adjusts the headers when the request body is read. But this is too late. For example, if a content generator module needs to look at the request headers before reading the request body, the content generator module "sees" the old (unmodified) headers.
mod_deflate should adjust the headers in an early stage, for example in a fixup hook (ap_hook_fixups).
mod_deflate
.看起来它在正确的轨道上:它吃
Content-Encoding
标题。无论如何,
Content-Length
还在那里。结果:还没有解压。所以,还有一些事情要做和适应,但问题肯定出在那个领域。
httpd version 2.4.34
):
diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c
index 1428460..cc8c0cb 100644
--- a/modules/filters/mod_deflate.c
+++ b/modules/filters/mod_deflate.c
@@ -1099,10 +1099,10 @@ static apr_status_t deflate_in_filter(ap_filter_t *f,
if (!ctx) {
/* only work on main request/no subrequests */
- if (!ap_is_initial_req(r)) {
+ /*if (!ap_is_initial_req(r)) {
ap_remove_input_filter(f);
return ap_get_brigade(f->next, bb, mode, block, readbytes);
- }
+ }*/
/* We can't operate on Content-Ranges */
if (apr_table_get(r->headers_in, "Content-Range") != NULL) {
mod_deflate
也处理子请求。我不确定它不会破坏其他一些模块,但它适用于您的用例(它更像是一个概念证明)。无论如何,我在上面提到的票上提出了我的补丁。这是结果的屏幕截图:
关于php - Apache RewriteRule 丢弃 SetInputFilter DEFLATE 配置指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44951644/
我在一个经常受到机器人网络攻击的网站工作。我们已经开始使用这个工具:http://deflate.medialayer.com/哪个自动禁止具有比设置值更多的开放连接的 ip。默认情况下它设置为 15
我看到一个奇怪的情况,Java 8u45 和 java.util.Deflater.deflate(byte[] b, int off, int len, int flush) 的输出缓冲区很小与小输
zlib docs指定可以将负的 windowBits 参数传递给 deflateInit2() 函数: windowBits can also be –8..–15 for raw deflate.
我写了一些 Javascript 代码。用base64压缩并放气 function base64 (str) { return new Buffer(str).toString("base64
在 Java 7 中,Deflater添加了对某些压缩参数的支持(模式:FULL_FLUSH、SYNC_FLUSH)。我猜他们对应的 Zlib 类似 constants在标准 API 中(虽然这个 A
我遇到了一些 zlib 压缩的不同实现之间不兼容的问题。 作为测试用例,我想创建具有 10000 个 double 的测试数据,范围从 0 到 10000。 我创建了一些测试代码来压缩和解压缩此数据,
我正在将一个 Python 应用程序移植到 Android,在某些时候,这个应用程序必须与 Web 服务通信,向它发送压缩数据。 为了做到这一点,它使用了下一个方法: def stuff(self,
我目前正在实现一个 png 阅读器,但我对数据的位顺序和一般格式感到困惑。 我无法访问 libpng、zlib 或类似软件。 请注意,我写的任何位串都是最高有效位在前。 根据 RFC1951 , "数
我目前正在实现一个 png 阅读器,但我对数据的位顺序和一般格式感到困惑。 我无法访问 libpng、zlib 或类似软件。 请注意,我写的任何位串都是最高有效位在前。 根据 RFC1951 , "数
我正在将大量对象保存到一个文件中,然后反序列化它们。生成的 xml 文件大小约为 3 gig。 我希望反序列化非常快,所以我尝试了所有三种方法(xml、二进制、压缩) 显然,反序列化压缩文件比 XML
这个问题在这里已经有了答案: Zlib deflated input is larger than original input string of chars? (3 个答案) 关闭 5 年前。
我目前正在尝试创建自定义 Deflate在 C# 中实现。 我目前正在尝试实现“模式搜索”部分,其中我有(最多)32k 的数据,并且正在尝试为我的输入搜索最长的可能模式。 RFC 1951定义 Def
我听到了关于MsgPack的一些信息,可用于压缩json消息,但是我对此有一个疑问,为什么不简单地使用Gzip / Deflate而不是MsgPack?我认为调试也更好。 最佳答案 msgpack是一
我花了大约 48 小时尝试解决 gzip deflate 问题,并意识到我可能需要寻求帮助,呵呵。 在意识到我需要在 php.ini 文件中打开压缩之后,我终于通过 .htaccess 在我的共享 U
让 zlib 在每个请求期间压缩网页似乎是多余的。这也是我的文件响应时间的瓶颈。有没有办法缓存 zlib 文件,以便每次修改时只压缩一次?还是我应该继续愿望? 最佳答案 如果您想要一个快速而懒惰的解决
我正在尝试找出如何禁用服务器上特定目录的 DEFLATE 模块(gzipping)。这是我在/etc/httpd/conf/httpd.conf 中的内容 AddOutputFilterByType
我正在开发一个文件压缩程序。我们目前正在实现 .ZIP 存档器标准,以便在生成压缩的 .ZIP 存档器时,任何其他信誉良好的压缩器(例如 7zip)都可以完美地理解/解压缩它。 我们现在正在开发基于R
我使用 Deflater 编写了一个备份程序SHA-1 用于存储文件和哈希值。我看到Java的Deflater使用zlib 。如果我显式设置 Deflater 的级别,无论平台和 JRE 版本如何,我
我想在保存到文件之前压缩字节数组。当我使用 Deflator 压缩字节数组时,出现 OutOfMemoryError: ERROR/dalvikvm-heap(16065): Out of memor
需要一些帮助来了解 DEFLATE 编码的工作原理。我知道这是 LZSS 算法和霍夫曼编码的组合。 因此,让我们编码例如“延迟放气”。参数:[Search buffer: 8kb and Look-a
我是一名优秀的程序员,十分优秀!