我正在 node.js 中实现静态文件服务。假设我要发送一个名为 party-time.txt
的文件,它是:
100 字节未压缩
gzipped 70 字节
如果我发送 gzipped 文件,Content-Length
header 应该是 100
还是 70
?
最佳答案
请看specification .它明确指出:
Applications SHOULD use this field to indicate the transfer-length of the message-body, unless this is prohibited by the rules in section 4.4.
深入挖掘:
The message-body (if any) of an HTTP message is used to carry the
entity-body associated with the request or response. The message-body differs from the entity-body only when a transfer-coding has been
applied, as indicated by the Transfer-Encoding header field (...)
所以,Content-length
就是压缩包的大小。
关于node.js - Content-Length header 是压缩字节还是未压缩字节的字节大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32145031/