Content-Length

The Content-Length header simply indicates the length of the content section of the HTTP message in bytes. An example of this header is given in the following HTTP response:

HTTP/1.1 200 OK 
Date: Tue, 21 May 2002 12:34:56 GMT 
Content-Type: text/html 
Content-Length: 102 

<html> 
<head> 
<title>Content-Length Example</title> 
</head> 
<body> 
Content-Length: 102 
</body> 
</html> 

In this example, the number of bytes between the first character of the content (the < of <html>) and the final character of the content (the > of </html>) inclusively is 102.

As I briefly mentioned in the discussion of the Connection general header, the Content-Length header is necessary when persistent connections are being used (and content is expected) in ...

Get HTTP Developer’s Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.