Modifying jQuery ajax request Connection header

为君一笑 提交于 2019-12-01 21:53:09

问题


I'm trying to modify the Connection header with the following code with no success

jQuery.ajax({
    url: URL,
    async: boolVariable,
    beforeSend: function(xhr)   
    {
        xhr.setRequestHeader("Connection", "close");
    }   
})

The request headers via Firebug show:

Connection  keep-alive
X-Requested-With    XMLHttpRequest

Any odd bugs/problems with setting this particular header known? Or is there something I'm doing wrong?


回答1:


According to the standard here you are not allowed to set the Connection header. It will terminate the set header. Also if you try this in webkit the console will output Refused to set unsafe header "Connection" So it looks like you will not be able to do what you want on the client side.



来源:https://stackoverflow.com/questions/2954958/modifying-jquery-ajax-request-connection-header

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