зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1437360 - do not attempt to parse XHRs as XML if content-length=0, to prevent logging "no root element found" errors; r=smaug
do not attempt to parse XHRs as XML if content-length=0, to prevent logging "no root element found" errors Differential Revision: https://phabricator.services.mozilla.com/D23444 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5ffebc7b88
Коммит
13eb2f8827
|
@ -1,6 +1,7 @@
|
||||||
function handleRequest(request, response)
|
function handleRequest(request, response)
|
||||||
{
|
{
|
||||||
let [status, statusText, body] = request.queryString.split("&");
|
let [status, statusText, encodedBody] = request.queryString.split("&");
|
||||||
|
let body = decodeURIComponent(encodedBody);
|
||||||
response.setStatusLine(request.httpVersion, status, statusText);
|
response.setStatusLine(request.httpVersion, status, statusText);
|
||||||
response.setHeader("Content-Type", "text/xml", false);
|
response.setHeader("Content-Type", "text/xml", false);
|
||||||
response.setHeader("Content-Length", "" + body.length, false);
|
response.setHeader("Content-Length", "" + body.length, false);
|
||||||
|
|
|
@ -19,6 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=884693
|
||||||
|
|
||||||
const SERVER_URL = "http://mochi.test:8888/tests/dom/base/test/chrome/bug884693.sjs";
|
const SERVER_URL = "http://mochi.test:8888/tests/dom/base/test/chrome/bug884693.sjs";
|
||||||
const INVALID_XML = "InvalidXML";
|
const INVALID_XML = "InvalidXML";
|
||||||
|
const XML_WITHOUT_ROOT = "<?xml version='1.0'?>";
|
||||||
|
|
||||||
let consoleService = Cc["@mozilla.org/consoleservice;1"].
|
let consoleService = Cc["@mozilla.org/consoleservice;1"].
|
||||||
getService(Ci.nsIConsoleService)
|
getService(Ci.nsIConsoleService)
|
||||||
|
@ -63,7 +64,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=884693
|
||||||
then(() => { return runTest(205, "Reset Content", INVALID_XML, "", []); }).
|
then(() => { return runTest(205, "Reset Content", INVALID_XML, "", []); }).
|
||||||
then(() => { return runTest(304, "Not modified", "", "", []); }).
|
then(() => { return runTest(304, "Not modified", "", "", []); }).
|
||||||
then(() => { return runTest(304, "Not modified", INVALID_XML, "", []); }).
|
then(() => { return runTest(304, "Not modified", INVALID_XML, "", []); }).
|
||||||
then(() => { return runTest(200, "OK", "", "", ["no root element found"]); }).
|
then(() => { return runTest(200, "OK", "", "", []); }).
|
||||||
|
then(() => { return runTest(200, "OK", XML_WITHOUT_ROOT, XML_WITHOUT_ROOT, ["no root element found"]); }).
|
||||||
then(() => { return runTest(200, "OK", INVALID_XML, INVALID_XML, ["syntax error"]); }).
|
then(() => { return runTest(200, "OK", INVALID_XML, INVALID_XML, ["syntax error"]); }).
|
||||||
then(SimpleTest.finish);
|
then(SimpleTest.finish);
|
||||||
|
|
||||||
|
|
|
@ -1888,6 +1888,15 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest* request) {
|
||||||
!(mRequestMethod.EqualsLiteral("HEAD") ||
|
!(mRequestMethod.EqualsLiteral("HEAD") ||
|
||||||
mRequestMethod.EqualsLiteral("CONNECT"));
|
mRequestMethod.EqualsLiteral("CONNECT"));
|
||||||
|
|
||||||
|
if (parseBody) {
|
||||||
|
// Do not try to parse documents if content-length = 0
|
||||||
|
int64_t contentLength;
|
||||||
|
if (NS_SUCCEEDED(mChannel->GetContentLength(&contentLength)) &&
|
||||||
|
contentLength == 0) {
|
||||||
|
parseBody = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mIsHtml = false;
|
mIsHtml = false;
|
||||||
mWarnAboutSyncHtml = false;
|
mWarnAboutSyncHtml = false;
|
||||||
if (parseBody && NS_SUCCEEDED(status)) {
|
if (parseBody && NS_SUCCEEDED(status)) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче