Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 638
Kirk Ouimet Avatar asked Aug 21 '15 16:08

Kirk Ouimet


1 Answers

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.

like image 64
Opal Avatar answered Oct 16 '22 04:10

Opal