Content-Length header 是压缩字节还是未压缩字节的字节大小?

Is the Content-Length header the size in bytes of the compressed or uncompressed bytes?

我正在 node.js 中实现静态文件服务。假设我要发送一个名为 party-time.txt 的文件,它是:

100 bytes uncompressed

70 bytes 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就是压缩后的body大小