Matt Joiner
Matt Joiner

Reputation: 118470

HTTP Content-Length and Content-Encoding

Does the HTTP response header Content-Length pertain to the length before or after decoding the body due to Content-Encoding: gzip?

Upvotes: 18

Views: 8490

Answers (1)

Amadan
Amadan

Reputation: 198294

It is raw length of whatever is in the HTTP body. This allows the HTTP client to detect the end of the transmission in cases of persistent connection. Thus, if the body is 10000 bytes pre-compression but 5000 bytes compressed, length is 5000; counting from the end of the header, 5001th byte received will be part of a new HTTP transmission.

Upvotes: 24

Related Questions