Get Response header 關鍵字用來獲取http請求返回的http響應頭部數據。javascript
常見的Response Header:html
Headerjava |
解釋web |
示例json |
Accept-Ranges瀏覽器 |
代表服務器是否支持指定範圍請求及哪一種類型的分段請求緩存 |
Accept-Ranges: bytes服務器 |
Age網絡 |
從原始服務器到代理緩存造成的估算時間(以秒計,非負)app |
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
【原文歸做者全部,歡迎轉載,可是保留版權】