7 月 122011
 

原文(source): linux curl get http header-筆記

在linux下使用curl查看一個鏈接的header的辦法更為直接,另外,它還可以通過修改request header來對目標地址進行調試,非常方便:

curl -I http://www.sudone.com

這樣就可以看到response header了,但是這個header是無壓縮的,所以並不是大多數人所取得的header。要查看壓縮版本,執行:

curl -I –compressed http://www.sudone.com

這是使用了curl默認的請求壓縮功能,但這個功能在某些時候還是不能取得壓縮版本……,執行一個最為原始的:

curl -I -H “Accept-Encoding:gzip, deflate” http://www.sudone.com

這個辦法對所有的可支持gzip或defalte壓縮的服務器,都是生效的,如果還是沒有壓縮(沒有返回Content-Encoding:gzip),那就是服務器沒有支持壓縮的了。

順帶記錄一個curl檢查指定ip的鏈接的辦法,這個對lvs集群下某台機的檢查是非常有用的:

curl -I -H “Host:www.sudone.com” -H “Accept-Encoding:gzip, deflate” http://64.233.189.99/

附帶一個wget的用法:

wget -S –spider http://www.baidu.com

=============================================

檢查 Keep-Alive

curl -H ‘Connection: Keep-Alive’ -I http://yahoo.com

 

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

CAPTCHA Image
Play CAPTCHA Audio
Reload Image