javascript/jquery读取和修改HTTP headers
注意::W3规定XMLHttpRequest并不能修改全部的HTTP Headers,而仅是一小部分。
比如:
Host: localhost:58188
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
role:2
username:106110454@qq.com
password:lw=kQH
password:1
jquery获取HTTP headers:
test.html:
jQuery通过XMLHttpRequest的getResponseHeader或getAllResponseHeaders()可以获取指定的HTTP header field的值,但规定不能获取Set-Cookie和Set-Cookie2的值。
参考:
http://stackoverflow.com/questions/1145588/cannot-properly-set-the-accept-http-header-with-jquery
http://stackoverflow.com/questions/2444489/getresponseheader-is-not-a-function