Is it possible to, before sending a http message, remove some specific http headers using javascript / XmlHttpRequest ?
I\'m using a proprietary browser, so there\'s
Adam's answer didn't work for me. However, the following did:
xhr.setRequestHeader('Authorization', ' ');
notice, second parameter is a string containing a space instead of empty space. It does not remove header completely, but sets it to the empty string, which might be enough for some cases.
Never done it, but in theory you could try:
xhr.setRequestHeader('Authorization', null);
There's also an unspecified removeRequestHeader()
function in some implementations, you may want to give it a try as well.
You could use the setRequestHeader method of the XmlHttpRequest object assuming your browser supports it, It is part of the W3C spec. It is also implemented by IE.
var req = new XMLHttpRequest();
req.setRequestHeader("Authorization", "");
When I use jquery-file-upload, and want to remove the header in the options
method, setting it to null
or ''
doesn't work for me. I use this instead:
req.setRequestHeader("Authorization");