http header
Content-Length header
The HTTP Content-Length header indicates the size, in bytes, of the message body sent to the recipient.
Content-Length is limited in that the message size must be known up front, before sending the headers, which is a problem when content is dynamically generated or streamed.
- In HTTP/1.0, it is required.
- In HTTP/1.1, it could be replaced with
Transfer-Encoding: chunkedfor responses sent out in parts as its size is calculated. - In HTTP/2,
Content-Lengthis redundant, because the content length may be inferred from DATA frames. It may still be included for backwards compatibility.
| Header type | [Request header](https://developer.mozilla.org/en-US/docs/Glossary/Request%20header), [Response header](https://developer.mozilla.org/en-US/docs/Glossary/Response%20header), [Content header](https://developer.mozilla.org/en-US/docs/Glossary/Content%20header) |
|---|---|
| [Forbidden request header](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden%20request%20header) | Yes |
| [CORS-safelisted response header](https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted%20response%20header) | Yes |
Syntax
Content-Length: <length>
Directives
<length>- : The length in octets.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.