Content-Length Header

The Content-Length HTTP header is used to indicate the size of the message body, in decimal number of OCTETs.

The Content-Length header is used to let the receiving party know when the current message has ended, so the connection can be closed or reused for another request.

Alternatively, the Content-Length header may be omitted and the "Transfer-Encoding: chunked" header may be used instead. If both the Content-Length and Transfer-Encoding headers are missing, then the connection should be closed at the end of the response.

POST Request With Content-Length Header Example Live Request
POST /echo/post/json HTTP/1.1
Host: reqbin.com
Content-Type: application/json
Content-Length: 473

{...}

Both the client and server can specify the Content-Length header and indicate that the message has a body. Any Content-Length value greater than or equal to zero is a valid value.

If the value of the Content-Length header is zero, or if neither the Transfer-Encoding header nor the Content-Length header is specified, then the message has no body.
http-headers content-length