Bug 382947 - XMLHttpRequest should only set the charset in the Content-Type request header if we know the charset, patch by Ryan Jones <sciguyryan@gmail.com>, r=bzbarsky, sr=peterv

This commit is contained in:
philringnalda@gmail.com 2007-07-08 19:33:07 -07:00
Родитель 029c6cedd1
Коммит 765b50b310
1 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -1599,6 +1599,7 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
nsCOMPtr<nsIInputStream> stream(do_QueryInterface(supports));
if (stream) {
postDataStream = stream;
charset.Truncate();
}
}
}
@ -1648,8 +1649,18 @@ nsXMLHttpRequest::Send(nsIVariant *aBody)
contentType = NS_LITERAL_CSTRING("application/xml");
}
contentType.AppendLiteral(";charset=");
contentType.Append(charset);
// We don't want to set a charset for streams.
if (!charset.IsEmpty()) {
nsCAutoString actualType, dummy;
rv = NS_ParseContentType(contentType, actualType, dummy);
if (NS_FAILED(rv)) {
actualType.AssignLiteral("application/xml");
}
contentType.Assign(actualType);
contentType.AppendLiteral(";charset=");
contentType.Append(charset);
}
rv = uploadChannel->SetUploadStream(postDataStream, contentType, -1);
// Reset the method to its original value