Content-Length header with HEAD requests?

后端 未结 5 1842
情书的邮戳
情书的邮戳 2020-11-27 14:45

The http spec says about the HEAD request:

The HEAD method is identical to GET except that the server MUST NOT return a message-body in t

5条回答
  •  感动是毒
    2020-11-27 15:28

    Yes, the Content-Length of a HEAD response SHOULD, but not always does (see @Paul's answer) include the Content-Length value of a GET response:

    Stack Overflow does:

    > telnet stackoverflow.com 80
    HEAD / HTTP/1.1
    Host: stackoverflow.com
    
    
    HTTP/1.1 200 OK
    Cache-Control: public, max-age=60
    Content-Length: 362245                           <--------
    Content-Type: text/html; charset=utf-8
    Expires: Mon, 04 Oct 2010 11:51:49 GMT
    Last-Modified: Mon, 04 Oct 2010 11:50:49 GMT
    Vary: *
    Date: Mon, 04 Oct 2010 11:50:49 GMT
    

    Google doesn't:

    > telnet www.google.com 80
    HEAD / HTTP/1.1
    Host: www.google.ie
    
    
    HTTP/1.1 200 OK
    Date: Mon, 04 Oct 2010 11:55:36 GMT
    Expires: -1
    Cache-Control: private, max-age=0
    Content-Type: text/html; charset=ISO-8859-1
    Server: gws
    X-XSS-Protection: 1; mode=block
    Transfer-Encoding: chunked
    

提交回复
热议问题