views:

204

answers:

2

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 no way to do it using browser specific solution.

For example, I want to remove the header 'Authorization' before send the message

POST /social/rpc?oauth_version=1.0& ... HTTP/1.1

Accept: text/html, image/png, image/*, */*
Accept-Language: ko
Authorization: Basic Og==
Host: test.myhost.com

Regards

+1  A: 

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.

BalusC
+2  A: 

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", "");
Adam
I just figure out now that this is no longer necessary for me. I thought it was causing problems but not. Thanks anyway.
Andres