HTTPS下請求HTTP時用戶端不帶Referer頭部,httpsreferer
作者:zhanhailiang 日期:2015-01-08
今天,測試發現在
https://mlogin.vip.com/user-login.html?back_act=http%3A%2F%2Fm.vip.com%2Fuser.html
下上報監控資料
http://mstats.vip.com/v1/timing/m?_t=1420647129290&p2=240&p4=377&t0=0&t1=63&t2=474&t3=642&t4=1&t6=411&t7=919&t8=3&t9=1059
老是報412:
GET http://mstats.vip.com/v1/timing/m?_t=1420647129290&p2=240&p4=377&t0=0&t1=63&t2=474&t3=642&t4=1&t6=411&t7=919&t8=3&t9=1059 412 (Precondition Failed)
看了監控平台的代碼,返回狀態代碼412是因為監控平台需要通過Referer頭部來判斷平台,但是該次請求卻無Referer頭部:
GET /v1/timing/m?_t=1420647129290&p2=240&p4=377&t0=0&t1=63&t2=474&t3=642&t4=1&t6=411&t7=919&t8=3&t9=1059 HTTP/1.1Host: mstats.vip.comConnection: keep-alivePragma: no-cacheCache-Control: no-cacheAccept: image/webp,*/*;q=0.8User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36DNT: 1Accept-Encoding: gzip, deflate, sdchAccept-Language: en-US,en;q=0.8Cookie: m_vip_province=104104; WAP[p_wh]=VIP_NH; warehouse=VIP_NH; wap_A1_sign=1; wap_consumer=A1; mars_pid=105; mars_cid=1420628456366_8d67e997a179843a61b1d3151d6bb9db; mars_sid=a4148eed668a36b75d29c288580f7099; visit_id=628ED24779611F6233FA107A22B83450
確實要求標頭沒有Referer頭部,原來是因為HTTP協議規定:
Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.
參考文章:
- [原]HTTPS 與 Referer 頭部丟失的問題