Bug 362043 - XMLHttpRequest should set a charset in the Content-Type request header
p=Ryan Jones <sciguyryan@gmail.com> r+sr=peterv git-svn-id: svn://10.0.0.236/trunk@226354 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
8ba3d82665
commit
98dcec3ccd
@ -1544,6 +1544,7 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
||||
if (aBody && httpChannel && !method.EqualsLiteral("GET")) {
|
||||
nsXPIDLString serial;
|
||||
nsCOMPtr<nsIInputStream> postDataStream;
|
||||
nsCAutoString charset(NS_LITERAL_CSTRING("UTF-8"));
|
||||
|
||||
PRUint16 dataType;
|
||||
rv = aBody->GetDataType(&dataType);
|
||||
@ -1568,6 +1569,11 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
|
||||
nsCOMPtr<nsIDOMSerializer> serializer(do_CreateInstance(NS_XMLSERIALIZER_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> baseDoc(do_QueryInterface(doc));
|
||||
if (baseDoc) {
|
||||
charset = baseDoc->GetDocumentCharacterSet();
|
||||
}
|
||||
|
||||
// Serialize to a stream so that the encoding used will
|
||||
// match the document's.
|
||||
nsCOMPtr<nsIInputStream> 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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user