Change jQuery ajax request connection header

I am trying to change the connection header with the following code without success

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

Request headers through Firebug show:

Connection  keep-alive
X-Requested-With    XMLHttpRequest

Any odd errors / issues setting this particular header? Or is there something I'm doing wrong?

+3
source share
1 answer

According to the standard here, you are not allowed to set the Connection header. It will complete the given title. Also, if you try this in webkit, the console will display Refused to set the unsafe "Connection" header. Thus, it seems that you cannot do what you want on the client side.

+4

Source: https://habr.com/ru/post/1748088/


All Articles