Refused to set unsafe header “Connection”

淺唱寂寞╮ 提交于 2019-12-30 10:24:29

问题


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.

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"".

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.

Thanks in advance.


回答1:


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


来源:https://stackoverflow.com/questions/22481945/refused-to-set-unsafe-header-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!