HTTP Content-Length and Content-Encoding
Asked Answered
N

1

18

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

Nadanadab answered 24/3, 2016 at 6:53 Comment(0)
I
24

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.

Insurrection answered 24/3, 2016 at 7:2 Comment(2)
Can you provide a link to an authoritative source?Nadanadab
RFC2616: "The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs ... 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." (emphasis mine). The exceptions all deal with cases when Content-Length header is not applicable.Insurrection

© 2022 - 2024 — McMap. All rights reserved.