我正在尝试让我的Web服务器正确地对分块编码的http响应进行gzip压缩。
我对非gzip响应的理解是它看起来像这样:
<the response headers>
接着,对于每个块,
<chunk length in hex>\r\n<chunk>\r\n
最后,一个长度为零的块:
0\r\n\r\n
我尝试启用gzip压缩,但需要帮助弄清楚应该返回什么内容。这份文档暗示着整个响应应该被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"。 有人能解释一下必须对上述方案进行哪些更改以支持分块的gzipping吗? 谢谢。