我可以删除的X请求 - 从Ajax请求的头? [英] can i remove the X-Requested-With header from ajax requests?

查看:223
本文介绍了我可以删除的X请求 - 从Ajax请求的头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如果任何人有这样的经验,试图从jQuery的(或纯JS)提出的Ajax请求删除X-要求,随着头。这可能吗?

第二部分:你知道,如果油猴的Ajax请求,设置这个标题

感谢

标题是这样的:

  X-要求,随着XMLHtt prequest
 

解决方案
  

第2部分:?你知不知道,如果油猴的Ajax请求,设置这个头

没有,的Greasemonkey的 GM_xmlhtt prequest() 不设置这个头(虽然你当然可以将其添加)。

GM_xmlhtt prequest()发布的默认请求看起来就像一个普通的浏览器请求。
例如:

  GM_xmlhtt prequest
({
    方法:GET,
    网址:http://google.com/
    的onload:函数(响应){警报(response.responseText); }
});
 


看起来这给我的包嗅探器:

  GET / HTTP / 1.1
    请求方法:GET
    请求URI:/
    请求版本:HTTP / 1.1
主持人:google.com
用户代理:Mozilla的/ 5.0(Windows系统; U; Windows NT的5.1; EN-US; rv中:1.9.2.8)的Gecko / 20100722 Firefox的/ 3.6.8
接受:text / html的,是application / xhtml + xml的,应用程序/ XML; Q = 0.9,* / *; Q = 0.8
接受语言:EN-US,EN; Q = 0.5
接受编码:gzip,紧缩
接收字符集:UTF-8,*
保持活动:115
连接:保持活动
饼干:等等,等等,等等,等等,等等...
 

I wanted to know if anyone has had experience with trying to remove the 'X-Requested-With' header from the ajax request made by jquery (or plain JS). is it possible?

2nd part: do you know if Grease Monkey's ajax requests set this header?

Thanks

header looks like this:

X-Requested-With XMLHttpRequest

解决方案

"2nd part: do you know if Grease Monkey's ajax requests set this header?"

No, Greasemonkey's GM_xmlhttpRequest() does not set this header (although you can certainly add it).

The default request issued by GM_xmlhttpRequest() looks just like a normal browser request.
For example:

GM_xmlhttpRequest
({
    method:     "GET",
    url:        "http://google.com/",
    onload:     function(response) {alert(response.responseText); }
});


Looks like this to my packet sniffer:

GET / HTTP/1.1
    Request Method: GET
    Request URI: /
    Request Version: HTTP/1.1
Host: google.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: UTF-8,*
Keep-Alive: 115
Connection: keep-alive
Cookie: blah, blah, blah, blah, blah...

这篇关于我可以删除的X请求 - 从Ajax请求的头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆