Get Response header 關鍵字用來獲取http請求返回的http響應頭部數據。
常見的Response Header:
Header |
解釋 |
示例 |
Accept-Ranges |
表明服務器是否支持指定范圍請求及哪種類型的分段請求 |
Accept-Ranges: bytes |
Age |
從原始服務器到代理緩存形成的估算時間(以秒計,非負) |
Age: 12 |
Allow |
對某網絡資源的有效的請求行為,不允許則返回405 |
Allow: GET, HEAD |
Cache-Control |
告訴所有的緩存機制是否可以緩存及哪種類型 |
Cache-Control: no-cache |
Content-Encoding |
web服務器支持的返回內容壓縮編碼類型。 |
Content-Encoding: gzip |
Content-Language |
響應體的語言 |
Content-Language: en,zh |
Content-Length |
響應體的長度 |
Content-Length: 348 |
Content-Location |
請求資源可替代的備用的另一地址 |
Content-Location: /index.htm |
Content-MD5 |
返回資源的MD5校驗值 |
Content-MD5: Q2hlY2sgSW50ZWdyaXR5IQ== |
Content-Range |
在整個返回體中本部分的字節位置 |
Content-Range: bytes 21010-47021/47022 |
Content-Type |
返回內容的MIME類型 |
Content-Type: text/html; charset=utf-8 |
Date |
原始服務器消息發出的時間 |
Date: Tue, 15 Nov 2010 08:12:31 GMT |
ETag |
請求變量的實體標簽的當前值 |
ETag: “737060cd8c284d8af7ad3082f209582d” |
Expires |
響應過期的日期和時間 |
Expires: Thu, 01 Dec 2010 16:00:00 GMT |
Last-Modified |
請求資源的最后修改時間 |
Last-Modified: Tue, 15 Nov 2010 12:45:26 GMT |
Location |
用來重定向接收方到非請求URL的位置來完成請求或標識新的資源 |
Location: http://www.zcmhi.com/archives/94.html |
Pragma |
包括實現特定的指令,它可應用到響應鏈上的任何接收方 |
Pragma: no-cache |
Proxy-Authenticate |
它指出認證方案和可應用到代理的該URL上的參數 |
Proxy-Authenticate: Basic |
refresh |
應用於重定向或一個新的資源被創造,在5秒之后重定向(由網景提出,被大部分瀏覽器支持) |
Refresh: 5; url= http://www.zcmhi.com/archives/94.html |
Retry-After |
如果實體暫時不可取,通知客戶端在指定時間之后再次嘗試 |
Retry-After: 120 |
Server |
web服務器軟件名稱 |
Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) |
Set-Cookie |
設置Http Cookie |
Set-Cookie: UserID=JohnDoe; Max-Age=3600; Version=1 |
Trailer |
指出頭域在分塊傳輸編碼的尾部存在 |
Trailer: Max-Forwards |
Transfer-Encoding |
文件傳輸編碼 |
Transfer-Encoding:chunked |
Vary |
告訴下游代理是使用緩存響應還是從原始服務器請求 |
Vary: * |
Via |
告知代理客戶端響應是通過哪里發送的 |
Via: 1.0 fred, 1.1 nowhere.com (Apache/1.1) |
Warning |
警告實體可能存在的問題 |
Warning: 199 Miscellaneous warning |
WWW-Authenticate |
表明客戶端請求實體應該使用的授權方案 |
WWW-Authenticate: Basic |
雖然http的Response Header類型眾多,但是並不是所有的請求都會返回所有的每一個Response Header。
示例1:訪問蘇寧易購網站上的http推薦接口,使用Get Response Header關鍵字獲取返回的http 頭部為Content-Type的數據。
Create Http Context tuijian.suning.com scheme=http
GET /recommend-portal/recommendv2/biz.jsonp?callback=showFinal¶meter=%E7%AC%94%E8%AE%B0%E6%9C%AC&sceneIds=2-1&count=5&cityId=9173&price=&brandCode=
${header} Get Response Header Content-Type
log ${header}
執行結果:
從返回的結果看,我們獲取到的Content-Type 為application/javascript; charset=UTF-8
【原文歸作者所有,歡迎轉載,但是保留版權】