Overriding Content-Type as req.setRequestHeader("Content-Type", "text/plain; charset='some-encoding'"); req.send(aString); makes the sent string be encoded as "some-encoding" in WebKit, but not in MSIE or Firefox, where it's always sent as UTF-8. The XMLHttpRequest spec draft mandates IE/Firefox behavior, of course. Additionally, looking at Content-Type further complicates the choice of encoding for documents, see bug 11695.
Created attachment 12298 [details] proposed patch
Comment on attachment 12298 [details] proposed patch r=me
Committed revision 18675.