HTTP header field name case sensitivity

David Oliver
13 December 2012, 23:10
Hi Hugo,

I'm finding that in IE 9 and other browsers, PHP's env('HTTP_X_REQUESTED_WITH') gives "XMLHttpRequest" when an Ajax request is made, but that in IE 8 it doesn't.

IE 8 sends "x-requested-with: XMLHttpRequest" instead of the more usual "X-Requested-With: XMLHttpRequest". Is this difference in field name case the reason? says that HTTP header field names are case-insensitive.

The Hiawatha changelog has "Case-insensitive HTTP-header matching" down against version 3.5.

Hiawatha version: 8.0
Operating System: GNU/Linux, Debian / Ubuntu
David Oliver
13 December 2012, 23:15
I found , which mentions version 6.10.

I don't know C, but perhaps 'headerfield_to_environment(session, fcgi_buffer, "X-Requested-With:", "HTTP_X_REQUESTED_WITH");' makes the field name case sensitive?
Hugo Leisink
14 December 2012, 00:07
Hiawatha does have case insensitive header matching. Are you saying that with IE8 the HTTP_X_REQUESTED_WITH environment variable is not set? I just tested it and it worked just fine.
David Oliver
14 December 2012, 00:27
Yes, it seems it's not set for me in IE8. With IE8, the following PHP does not return 'XMLHttpRequest':


I tested the above from within a CakePHP app view by echoing it. In IE8, The value ("XMLHttpRequest") is not output when the codebase is running on Hiawatha, but it is when running on Apache, and, likewise, the associated Ajax functionality doesn't/does work.

It's used in CakePHP 1.3 here:
Hugo Leisink
14 December 2012, 07:32
Upgrade to the latest version (or at least 8.5) and your problem will be solved.
David Oliver
14 December 2012, 23:03
On 8.6 now, and all's well. Thanks for the help.
This topic has been closed.