HTTP协议支持自定义的HTTP请求头和HTTP响应头

自定义HTTP请求头

自定义HTTP响应头

  • 百度首页
    curl --head http://www.baidu.com/ -L
    HTTP/1.1 200 OK
    Date: Sat, 16 Mar 2013 13:05:48 GMT
    Server: BWS/1.0
    Content-Length: 10299
    Content-Type: text/html;charset=utf-8
    Cache-Control: private
    Expires: Sat, 16 Mar 2013 13:05:48 GMT
    Set-Cookie: H_PS_PSSID=1461_1945_1788; path=/; domain=.baidu.com
    Set-Cookie: BAIDUID=13E06E5B5028459301724FC23A5DA57F:FG=1; expires=Sat, 16-Mar-43 13:05:48 GMT; path=/; domain=.baidu.com
    P3P: CP=" OTI DSP COR IVA OUR IND COM "
    Connection: Keep-Alive
    

注意到上面所有服务器设置的时间均使用到了一个关键词GMT,简单来说这是为了解决全球不同地区的时区差异问题而进行的一项关于时间的标准化设置。

  • Google首页
$ curl --head https://www.google.com/ -L
HTTP/1.1 302 Found
Location: http://www.google.com.hk/url?sa=p&hl=zh-CN&pref=hkredirect&pval=yes&q=http://www.google.com.hk/&ust=1363438927420121&usg=AFQjCNFdSfUt96IedwczFyY_nPYC3ejWuw
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Set-Cookie: PREF=ID=2910a5c845d5e1b2:FF=0:NW=1:TM=1363438897:LM=1363438897:S=XmLijrDUDKdiz96X; expires=Mon, 16-Mar-2015 13:01:37 GMT; path=/; domain=.google.com
Date: Sat, 16 Mar 2013 13:01:37 GMT
Server: gws
Content-Length: 376
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN

HTTP/1.1 302 Found
X-Frame-Options: ALLOWALL
Location: http://www.google.com.hk/
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Set-Cookie: PREF=ID=a55630dc738133db:FF=2:LD=zh-CN:NW=1:TM=1363438897:LM=1363438897:S=jFUaVYSm5frOziFt; expires=Mon, 16-Mar-2015 13:01:37 GMT; path=/; domain=.google.com.hk
Set-Cookie: NID=67=q9raMsCzu8dv3ocY7c0QAddUnW5ire1ULB9TUwzzHbzxDnIjbDtqENJZGp7ZyyI5Hnhjz6GAYt_QAbDtcjK7DIQvksyQeb91Idn7I70UoJxkxADWOQOO3F8H5VWK0D14; expires=Sun, 15-Sep-2013 13:01:37 GMT; path=/; domain=.google.com.hk; HttpOnly
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
Date: Sat, 16 Mar 2013 13:01:37 GMT
Server: gws
Content-Length: 222
X-XSS-Protection: 1; mode=block

HTTP/1.1 200 OK
Date: Sat, 16 Mar 2013 13:01:37 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=Big5
Set-Cookie: PREF=ID=93700084ed34fe95:FF=0:NW=1:TM=1363438897:LM=1363438897:S=4nSbOVk98Wo186kE; expires=Mon, 16-Mar-2015 13:01:37 GMT; path=/; domain=.google.com.hk
Set-Cookie: NID=67=MGsopB-4bLgSW8WyTrB7PsLbhUeMRgAtt5qoXSF4PMltsY6is2n2IGQ7Ho2Vfk0lgM3DqdL12029V37dX1ALSYezoC3KlVIo9F7qw-b0XJq9N3LVziczOfPqPPypzmtZ; expires=Sun, 15-Sep-2013 13:01:37 GMT; path=/; domain=.google.com.hk; HttpOnly
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
Server: gws
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Transfer-Encoding: chunked

参考文献

返回顶部