How can FireFox be forced to use a specific content type for XMLHttpRequest without appending the charset parameter after the type itself?
I am using FireFox 15 to extract some data out of a very custom http server. The server takes JSON from the POST body and responds with another JSON. The server accepts only “Content-Type: application/json” as valid content type. Anything after except this exact header will not be recognized by the server as valid content type.
When I use the below code in Chrome it sets the content type as expected “Content-Type: application/json”
var invocation = new XMLHttpRequest();
invocation.open('POST', url, true);
invocation.setRequestHeader('Content-Type', 'application/json');
invocation.onreadystatechange = function(data){ /* some processing */ };
invocation.send(body);
The issue is that FireFox sets the content type to “Content-Type: application/json; charset=UTF-8”.
According to bugzilla using sendAsBinary is a possible workaround.