I'm implementing static file serving in node.js. Let's say I am sending a file called party-time.txt
which is:
100 bytes uncompressed
70 bytes gzipped
If I send the file gzipped, should the Content-Length
header be 100
or 70
?
Please have a look at the specification. It clearly states:
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.
Digging deeper:
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 (...)
So, the Content-length
is the size of compressed body.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With