Opera Technology Preview 9 and XMLHttpRequest http headers
Update: I get one request for the favicon.ico on every XMLHttpRequest request, that is strange, too.
If you are using the XMLHttpRequest object you have to be careful for the .setRequestHeader method. To override header values in Opera 9 you have to use the exact name of the header.
xmlhttp.setRequestHeader("Content-type", "abc");
The example above will add a new header to the list:
Content-type: abc
Content-Type: text/xml; charset=utf-8 (the default)
Another example is this:
xmlhttp.setRequestHeader("Content-type", "abc");
xmlhttp.setRequestHeader("content-type", "test");
You will have still have only two headers for the content type, you get this http request now:
Content-type: abc, test
Content-Type: text/xml; charset=utf-8 (the default)
If you use case sensitive key names in your JavaScript code the XMLHttpRequest is working correct. To override the built-in headers you have to use the same notation:
xmlhttp.setRequestHeader("Content-Type", "abc");
xmlhttp.setRequestHeader("Content-Type", "test");
Now, you have only one http header for the content type, the default value is missing:
Content-Type: abc, test
3 Comments
Comments have been disabled for this content.
Martin said
How to set a header 'foo' that not be part of the commmons http headers..?
Michael Schwarz said
The problem was the different notation of the header name.
Paul said
I think the favicon.ico requests come from a MS Office toolbar