HTTP请求标头X-Requested-With来自哪里

mon*_*jer 9 xmlhttprequest http-headers

我们知道X-Requested-With,如果http请求来自Ajax,我们可以使用http请求标头来判断.

许多javascript框架会X-Requested-With在其ajax请求中自动添加标头,例如jQuery Ajax,Prototype Ajax.而作为HTTP标头字段列表的维基说,这X-Requested-With是一个非标准的请求标头.

谷歌多次后,我还没有找到谁首先提出X-Requested-With请求标题.

所以我想知道是否还有其他人知道它的X-Requested-With来源?谢谢...

Kev*_*son 6

如果有标准的X-Ajax-Engine请求标头,X-Requested-With可以找到对Prototype支持的引用(2006年6月30日发布).

参考在Github上jQuery的源代码库到2006年5月16日版本的ajax.js这里X-Requested-With原本被添加.

Dojo直到02/09/08都没有看到添加这个并引用其他库:

jQuery,Prototype,YUI和 - 看起来 - Mootools用他们的XHR发送标题"X-Requested-With:XMLHttpRequest".

2008-10-21 v1.4,MochiKit称之为标准:

MochiKit.Async现在设置了"X-Requested-With:XMLHttpRequest"标头,这是事实上的标准(Prototype,jQuery,Mootools).