【发布时间】:2011-07-13 22:20:36
【问题描述】:
我正在尝试让我的网络服务器正确地 gzip 一个块编码的 http 响应。
我对非 gzip 响应的理解是它看起来像这样:
<the response headers>
然后对于每个块,
<chunk length in hex>\r\n<chunk>\r\n
最后是一个零长度的块:
0\r\n\r\n
我试图让 gzip 压缩工作,我可以使用一些帮助来确定实际应该返回什么。该文档暗示应该压缩整个响应,而不是压缩每个块:
HTTP servers sometimes use compression (gzip) or deflate methods to optimize transmission.
Chunked transfer encoding can be used to delimit parts of the compressed object.
In this case the chunks are not individually compressed. Instead, the complete payload
is compressed and the output of the compression process is chunk encoded.
我尝试对整个内容进行 gzip 压缩并返回响应,即使没有分块,但它不起作用。我尝试将 Content-Encoding 标头设置为“gzip”。有人可以解释必须对上述方案进行哪些更改以支持块的 gzip 压缩吗?谢谢。
【问题讨论】:
标签: http gzip chunked-encoding