Content-Length
request & response headercontent
The size of the message body in bytes.
Content-Length tells the receiver exactly how many bytes of body follow, so it knows where the message ends and can show download progress. When the size isn't known in advance, HTTP/1.1 uses Transfer-Encoding: chunked instead; HTTP/2 and HTTP/3 frame the body themselves.
Syntax
Content-Length: <bytes>
Defined in RFC 9110 §8.6 — Content-Length.
Examples
Content-Length: 1024
a 1 KB body
Good to know
- It counts bytes, not characters:
"é"is one character but two bytes in UTF-8. - With compression, it's the compressed size.
- A value larger than the body makes clients hang waiting; a smaller one truncates it.
- Servers reject bodies over their limit with 413, often based on this header alone.
Further reading: 413 in nginx: raising the upload limit
Who sets Content-Length
Servers, frameworks and HTTP clients calculate Content-Length for you — setting it by hand is a common source of truncated or hanging responses. Check it with curl -sI https://example.com/ | grep -i content-length.
Check it
Fetch only the response headers and filter for Content-Length. In the browser, it's under Response Headers in DevTools → Network.
curl -sI https://example.com/ | grep -i '^content-length:'
To compare response headers across many URLs at once, use the HTTP Status Checker.
Frequently asked questions
Why is there no Content-Length on my response?
The body is being streamed or compressed on the fly, so the server sends it in chunks (HTTP/1.1) or frames (HTTP/2) instead.