diff --git a/mozilla/content/base/src/nsXMLHttpRequest.cpp b/mozilla/content/base/src/nsXMLHttpRequest.cpp index d4451e6a6f8..15f8e9ea62d 100644 --- a/mozilla/content/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/content/base/src/nsXMLHttpRequest.cpp @@ -1544,6 +1544,7 @@ nsXMLHttpRequest::Send(nsIVariant *aBody) if (aBody && httpChannel && !method.EqualsLiteral("GET")) { nsXPIDLString serial; nsCOMPtr postDataStream; + nsCAutoString charset(NS_LITERAL_CSTRING("UTF-8")); PRUint16 dataType; rv = aBody->GetDataType(&dataType); @@ -1568,6 +1569,11 @@ nsXMLHttpRequest::Send(nsIVariant *aBody) nsCOMPtr serializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rv)); if (NS_FAILED(rv)) return rv; + nsCOMPtr baseDoc(do_QueryInterface(doc)); + if (baseDoc) { + charset = baseDoc->GetDocumentCharacterSet(); + } + // Serialize to a stream so that the encoding used will // match the document's. nsCOMPtr input; @@ -1641,7 +1647,10 @@ nsXMLHttpRequest::Send(nsIVariant *aBody) contentType.IsEmpty()) { contentType = NS_LITERAL_CSTRING("application/xml"); } - + + contentType.AppendLiteral(";charset="); + contentType.Append(charset); + rv = uploadChannel->SetUploadStream(postDataStream, contentType, -1); // Reset the method to its original value if (httpChannel) {