Section 14.13 of the HTTP / 1.1 specification contains a detailed Content-Length header and says the following:
Applications SHOULD use this field to indicate the transmission length of the message body, unless prohibited by the rules in section 4.4.
The word “SHOULD” has a very specific meaning in the RFC :
- SHOULD This word or the adjective “RECOMMENDED” means that in certain circumstances there may be reasonable reasons to ignore a particular subject, but all the consequences must be understood and carefully considered before choosing another course.
Thus, you may not always see Content-Length. Normally, you may not see it for any content that is dynamically generated, as it may be too expensive to serve a HEAD search query. For example, a HEAD request for Apache for a static file will contain Content-Length, but a request for a PHP script may not be.
For example, try this website ...
telnet stackoverflow.com 80 HEAD / HTTP/1.0 Host:stackoverflow.com HTTP/1.1 200 OK Date: Mon, 11 Jan 2016 10:58:25 GMT Content-Type: text/html; charset=utf-8 Connection: close Set-Cookie: __cfduid=c2eb4742a1e02d89cab0402220736c0bd1452509905; expires=Tue, 10-Jan-17 10:58:25 GMT; path=/; domain=.stackoverflow.com; HttpOnly Cache-Control: public, no-cache="Set-Cookie", max-age=36 Expires: Mon, 11 Jan 2016 10:59:02 GMT Last-Modified: Mon, 11 Jan 2016 10:58:02 GMT Vary: * X-Frame-Options: SAMEORIGIN X-Request-Guid: 487e80bc-3783-4cfd-d883-a3bc84253234 Set-Cookie: prov=8dc24306-c067-45eb-bf5d-cffa855c2b03; domain=.stackoverflow.com; expires=Fri, 01-Jan-2055 00:00:00 GMT; path=/; HttpOnly Server: cloudflare-nginx CF-RAY: 26303c15f8e035a2-LHR
No content.
Paul Dixon Oct 04 '10 at 11:57 2010-10-04 11:57
source share