Content · Request & Response
Content-Length
The size of the body in bytes.
What is Content-Length?
Content-Length declares the exact size of the message body in bytes. Clients use it to allocate a buffer, show progress bars, and know when the body ends when connection reuse (keep-alive) is in play.
Typical usage
Set automatically by web servers. Only manually set when writing raw HTTP.
Examples
Content-Length: 348Common gotchas
Content-Length is mutually exclusive with Transfer-Encoding: chunked. Sending both is an HTTP protocol error.
Specification
RFC 9110 §8.6