3

It seems that XMLHttpRequest.setRequestHeader makes all header names lowercase, it's not against or by specs, since they leave a field for free interpretation around this, but does anyone know if there's any official statement or explanation to why browsers chose to do so?

You can try this code snippet in Chrome 17 or Firefox 10:

var xhr = new XMLHttpRequest;
xhr.open('get', 'someurl.php);
xhr.setRequestHeader('X-Test', 'one'); // gets lowercased down to "x-test"
xhr.send();
jayarjo
  • 16,124
  • 24
  • 94
  • 138
  • Which browser version are you seeing this behavior in? Can you post a code snippet that reproduces the issue? I don't see any mention of this in the XMLHttpRequest spec: http://www.w3.org/TR/XMLHttpRequest/#the-setrequestheader-method – monsur Mar 15 '12 at 19:26
  • Hmm, I can't reproduce this behavior. I just tried calling setRequestHeader() and it preserved the case. Are you using any custom libraries or frameworks that may be lowercasing the header? – monsur Mar 15 '12 at 20:04
  • Where do you see it preserving the case? Looking at it in FireBug and header name is lowercase, when sent. – jayarjo Mar 16 '12 at 06:54
  • I have the same issue and this ONLY happens when the protocol is HTTPS. I'm still looking for answers and I hope someone would answer this – PlanetCloud Nov 17 '18 at 06:44

0 Answers0