mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
No Issue - Do not parse or return body for XHRs with HEAD/CONNECT method or content-length=0
Based-on: m-c 1392220, 1437360
This commit is contained in:
parent
f1759b33ff
commit
84eadbe3cf
1 changed files with 19 additions and 7 deletions
|
|
@ -602,6 +602,12 @@ XMLHttpRequestMainThread::GetResponseText(XMLHttpRequestStringSnapshot& aSnapsho
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Main Fetch step 18 requires to ignore body for head/connect methods.
|
||||||
|
if (mRequestMethod.EqualsLiteral("HEAD") ||
|
||||||
|
mRequestMethod.EqualsLiteral("CONNECT")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// We only decode text lazily if we're also parsing to a doc.
|
// We only decode text lazily if we're also parsing to a doc.
|
||||||
// Also, if we've decoded all current data already, then no need to decode
|
// Also, if we've decoded all current data already, then no need to decode
|
||||||
// more.
|
// more.
|
||||||
|
|
@ -1915,13 +1921,19 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up responseXML
|
// Set up responseXML
|
||||||
bool parseBody = mResponseType == XMLHttpRequestResponseType::_empty ||
|
// Note: Main Fetch step 18 requires to ignore body for head/connect methods.
|
||||||
mResponseType == XMLHttpRequestResponseType::Document;
|
bool parseBody = (mResponseType == XMLHttpRequestResponseType::_empty ||
|
||||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel));
|
mResponseType == XMLHttpRequestResponseType::Document) &&
|
||||||
if (parseBody && httpChannel) {
|
!(mRequestMethod.EqualsLiteral("HEAD") ||
|
||||||
nsAutoCString method;
|
mRequestMethod.EqualsLiteral("CONNECT"));
|
||||||
httpChannel->GetRequestMethod(method);
|
|
||||||
parseBody = !method.EqualsLiteral("HEAD");
|
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;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue