Content-Length
The Content-Length
header specifies the length (in bytes) of the message body.
Writing messages
Set this header to the number of bytes that the message body occupies, which is sent immediately after the final ␍␊␍␊
. If the exact length is not yet known, the server can omit this header, but must use Connection: close
(if HTTP/1.0) or chunked encoding (if HTTP/1.1).
Reading messages
Implementations should ensure the provided number does not overflow the internal integer representation. This header is not the only way the message length may be calculated, see RFC 7230 §3.3.3. Message Body Length for how to determine the message body length.
Overview table
- Name
- Content-Length
- Description
- Specifies the size (bytes) of the attached message body.
- Direction
- Both
- Specification
- RFC 7230: HTTP/1.1 Message Syntax and Routing §3.3.2. Content-Length
Syntax
Content-Length = 1*DIGIT
Example
Content-Length: 3495