我试图让我的网络服务器正确地 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 压缩吗?谢谢。