Content-Length
The header that gives the size of the message body in bytes.
In more detail
It tells the receiver where the message ends. A HEAD response reports the length the body would have had, and a 204 or 304 has no body and so no length to report.
Related terms
- payload — The actual data a message carries, as opposed to the headers and framing around it.
- HEAD — The HTTP method that asks for exactly the headers a GET would return, but without the body.
- bytes, kilobytes, megabytes — Units of data size: a kilobyte is about a thousand bytes, a megabyte about a million, a gigabyte about a billion.
- chunked transfer encoding — An HTTP/1.1 way of sending a body of unknown length as a series of pieces, each preceded by its size, ending with an empty piece.
- HTTP header — A named line of metadata in an HTTP message, such as Content-Type: application/json, that describes the body, the caller or how to handle the exchange.
Taught in
- What An API Is, And The Alternatives — Modern API Architecture: REST, GraphQL & gRPC
- Headers And Content Negotiation — Modern API Architecture: REST, GraphQL & gRPC
- Caching And Conditional Requests — Modern API Architecture: REST, GraphQL & gRPC
- Native HTTP Server: Request & Response Lifecycles — Node.js Internals & Backend Services