Firefox 3 beta 5 - when sending XMLHTTPRequest, content-type request header is forced to ISO-8859-1 encoding instead of UTF-8
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <b0d77cf2-7b65-406b-b333-6822b0e0af68@a23g2000hsc.googlegroups.com> |
Hello,
I'm having problems with Firefox 3 beta 5 when sending UTF-8
characters via an XMLHTTPRequest.
I have read the following page: http://developer.mozilla.org/en/docs/XMLHttpRequest
which states:
Note: Versions of Firefox prior to version 3 always send the request
using UTF-8 encoding; Firefox 3 properly sends the document using the
encoding specified by data.xmlEncoding, or UTF-8 if no encoding is
specified.
In my test example, I attempt to explicitly set the content-type
header to "text/xml;charset=utf-8", as well as verify that the
xmlEncoding is null.
However, when I view the request headers in FF3 I see:
Content-Type text/xml; charset=ISO-8859-1
and the content on the server side is garbled
In FF2 I see:
Content-Type text/xml;charset=UTF-8
and t content is correctly encoded as UTF-8 on the server side
Here's an example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://
www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script language="javascript">
var dom = document.implementation.createDocument( "", "",
null );
var element = dom.createElement( "content" );
element.appendChild( dom.createTextNode( "üßäöüß" ) );
dom.appendChild( element );
var request = new XMLHttpRequest();
var url ="someURL";
request.open( "POST", url, true );
request.setRequestHeader( "Content-Type", "text/
xml;charset=utf-8" );
/* Firefox 3 should take it's cue from data.xmlEncoding,
according to
http://developer.mozilla.org/en/docs/XMLHttpRequest */
alert( "xmlEncoding? " + dom.xmlEncoding );
request.send( dom );
</script>
</head>
<body>
</body>
</html>
Does anyone have any idea on how to control this? Or how to set the
xmlEncoding property if necessary? Or what I'm doing wrong ;) ?
Thanks,
Peter