curl -i -X HEAD "www.baidu.com"
HTTP/1.1 200 OK
Server: bfe/1.0.8.18
Date: Mon, 12 Sep 2016 01:38:38 GMT
Content-Type: text/html
Content-Length: 277 (单位是字节)
Last-Modified: Mon, 13 Jun 2016 02:50:15 GMT
Connection: Keep-Alive
ETag: "575e1f67-115"
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Pragma: no-cache
Accept-Ranges: bytes
分别用1.0和1.1的HTTP版本请求返回的结果都是1.1版本的:
MacBook-Pro:untitled fazhao$ curl -i -X HEAD "www.baidu.com"
HTTP/1.1
HTTP/1.1 200 OK
Server: bfe/1.0.8.18
Date: Mon, 12 Sep 2016 01:44:18 GMT
Content-Type: text/html
Content-Length: 277
Last-Modified: Mon, 13 Jun 2016 02:50:15 GMT
Connection: Keep-Alive
ETag: "575e1f67-115"
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Pragma: no-cache
Accept-Ranges: bytes
^C
MacBook-Pro:untitled fazhao$ curl -i -X HEAD "www.baidu.com"
HTTP/1.0
HTTP/1.1 200 OK
Server: bfe/1.0.8.18
Date: Mon, 12 Sep 2016 01:44:24 GMT
Content-Type: text/html
Content-Length: 277
Last-Modified: Mon, 13 Jun 2016 02:50:18 GMT
Connection: Keep-Alive
ETag: "575e1f6a-115"
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Pragma: no-cache
Accept-Ranges: bytes
GET方法:
MacBook-Pro:untitled fazhao$ curl -i -X GET "www.baidu.com"
HTTP/1.1 200 OK
Server: bfe/1.0.8.18
Date: Mon, 12 Sep 2016 01:47:40 GMT
Content-Type: text/html
Content-Length: 2381(多出的是)
Last-Modified: Mon, 25 Jul 2016 11:11:53 GMT
Connection: Keep-Alive
ETag: "5795f3f9-94d"
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Pragma: no-cache
Accept-Ranges: bytes
使用httpie工具:
-h只显示head -b只显示body
MacBook-Pro:~ fazhao$ http -h www.baidu.com
HTTP/1.1 200 OK
BDPAGETYPE: 1
BDQID: 0x9febe0850002d472
BDUSERID: 0
Cache-Control: private
Connection: Keep-Alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Cxy_all: baidu+bb2f19927bcefa1faa6dc41e28dbad54
Date: Mon, 12 Sep 2016 02:26:26 GMT
Expires: Mon, 12 Sep 2016 02:25:30 GMT
P3P: CP=" OTI DSP COR IVA OUR IND COM "
Server: BWS/1.1
Set-Cookie: BAIDUID=702706592F7C4738A0BBD9464AE3C7C0:FG=1; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: BIDUPSID=702706592F7C4738A0BBD9464AE3C7C0; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: PSTM=1473647186; expires=Thu, 31-Dec-37 23:55:55 GMT; max-age=2147483647; path=/; domain=.baidu.com
Set-Cookie: BDSVRTM=0; path=/
Set-Cookie: BD_HOME=0; path=/
Set-Cookie: H_PS_PSSID=1429_21080_20857_21013_20732_20836_20719; path=/; domain=.baidu.com
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Powered-By: HPHP
X-UA-Compatible: IE=Edge,chrome=1
OPTIONS:
MacBook-Pro:~ fazhao$ http OPTIONS example.org
HTTP/1.1 200 OK
Allow: OPTIONS, GET, HEAD, POST
Cache-Control: max-age=604800
Content-Length: 0
Date: Mon, 12 Sep 2016 02:33:49 GMT
Expires: Mon, 19 Sep 2016 02:33:49 GMT
Server: EOS (lax004/28A3)
x-ec-custom-error: 1