开发者

header restrictions with XHR

开发者 https://www.devze.com 2023-02-15 11:06 出处:网络
does XMLHTTPR开发者_StackOverflowequest allow one to set \"any\" headers? Because it seems to be limiting me from setting the host header.No, as it will cause security issues. Please refer to W3C XMLH

does XMLHTTPR开发者_StackOverflowequest allow one to set "any" headers? Because it seems to be limiting me from setting the host header.


No, as it will cause security issues. Please refer to W3C XMLHttpRequest Level 2 spec, the setRequestHeader() method should terminate if header is a case-insensitive match for one of the following headers:

  • Accept-Charset
  • Accept-Encoding
  • Access-Control-Request-Headers
  • Access-Control-Request-Method
  • Connection
  • Content-Length
  • Cookie
  • Cookie2
  • Content-Transfer-Encoding
  • Date
  • Expect
  • Host
  • Keep-Alive
  • Origin
  • Referer
  • TE
  • Trailer
  • Transfer-Encoding
  • Upgrade
  • User-Agent
  • Via

Update: Konstantinos Filios is right that latest list can be found in WHATWG XMLHttprequest spec.

0

精彩评论

暂无评论...
验证码 换一张
取 消