How to remove HTTP specific headers in Javascript

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");