在 Apache httpd 中禁用 "Transfer-Encoding:chunked"

Disable "Transfer-Encoding:chunked" in Apache httpd

我们正在使用 Apache httpd 实现一些休息 API。我们有一个 API,它提供 9k 缓冲区作为响应。每当我们的响应超过 8k 时,Apache 将在响应 header 中附加 "Transfer-Encoding:chunked",其余响应 header 将被 Apache 丢弃。

我想在我们的响应缓冲区超过 8K 时禁用 "Transfer-Encoding:chunked" 响应 header 以保留我们有用的响应 headers。

谁能给我个主意?

mod_buffer 会导致许多响应从分块编码转为使用 Content-Length 发送。一般来说,无论谁生成对缓冲区的响应来确定长度,都会更有效率——但 mod_buffer 通常可以做到这一点。

它起作用的原因是 mod_buffer 阻止 headers 成为 written/committed 直到知道全长。