拒绝设置不安全的标题“连接” [英] Refused to set unsafe header "Connection"

查看:492
本文介绍了拒绝设置不安全的标题“连接”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发针对Android和iOS平台的跨平台应用程序。我使用的是jQuery 1.9.1,Jquery Mobile 1.3.1和Phonegap 2.8.0。

I am working on a cross platform application that targets Android and iOS platforms. I am using jQuery 1.9.1, Jquery Mobile 1.3.1 and Phonegap 2.8.0.

我想发送一个ajax请求并设置请求标题Connection和Keep-Alive。在操作系统大于4.1的Android手机上(默认浏览器是Chrome),我收到一条错误,上面写着拒绝设置不安全的标题连接。

I want to send an ajax request and set the request headers "Connection" and "Keep-Alive". On Android Phones with OS greater than 4.1 (Whose default browser is Chrome) I get an error which says "Refused to set unsafe header "Connection"".

我可以在低端设备上甚至在iPhone上发送此类请求。

I am able to send such requests on lower end devices and even on iPhones.

任何人都可以帮助我。

Can Anyone Please help me out.

我必须在请求中设置这两个标头。

I have to set these 2 headers in the request.

提前致谢。

推荐答案

部分 4.6.2 列出了由用户代理并且不允许使用 setRequestHeader()方法设置。 连接 Keep-Alive 都在该列表中。

Section 4.6.2 of the W3C XMLHttpRequest Level 1 spec lists headers that "are controlled by the user agent" and not allowed to be set with the setRequestHeader() method. Both Connection and Keep-Alive are in that list.

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

这篇关于拒绝设置不安全的标题“连接”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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