views:

1031

answers:

2

Why it is converting to lowercase? In Firefox it goes as: "X-Requested-With". While in IE, it goes as: "x-requested-with"

+4  A: 

The HTTP method is supposed to be case-sensitive, but the HTTP headers are supposed to be case-insensitive, according to RFC 2616.

Kieran Hall
So the answer to "why is IE doing this" is "because it can" ;-)
VolkerK
Kieran Hall
+4  A: 

I had noticed something similar. Take a look at the sample code and what it does when I add some custom HTTP headers. First is the JavaScript code and then is the Fiddler dump (custom headers only) from IE8, Safari4 and Firefox3. Notice that Firefox honors case, IE converts to lowercase and Safari converts to propercase.

However, as already mentioned, these are treated as case insensitive by the server so it really doesn't matter.

function doXHR() {
  var request = new XMLHttpRequest();
  request.open('GET', '/header/header.txt');
  request.setRequestHeader('x-lowercase', 'X-lowercase');
  request.setRequestHeader('x-Propercase', 'X-Propercase');
  request.setRequestHeader('x-CamelCase', 'X-CamelCase');
  request.setRequestHeader('x-UPPERCASE', 'X-UPPERCASE');
  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      console.log('Received XMLHttpRequest callback: \n' + request.responseText);
    }
  };
  request.send("");
}

User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618)

x-lowercase: X-lowercase
x-camelcase: X-CamelCase
x-uppercase: X-UPPERCASE
x-propercase: X-Propercase

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Safari/528.17

X-Lowercase: X-lowercase
X-Uppercase: X-UPPERCASE
X-Camelcase: X-CamelCase
X-Propercase: X-Propercase

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)

x-lowercase: X-lowercase
x-Propercase: X-Propercase
x-CamelCase: X-CamelCase
x-UPPERCASE: X-UPPERCASE
Kevin Hakanson