mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +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;
|
||||
}
|
||||
|
||||
// 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.
|
||||
// Also, if we've decoded all current data already, then no need to decode
|
||||
// more.
|
||||
|
|
@ -1915,13 +1921,19 @@ XMLHttpRequestMainThread::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
|||
}
|
||||
|
||||
// Set up responseXML
|
||||
bool parseBody = mResponseType == XMLHttpRequestResponseType::_empty ||
|
||||
mResponseType == XMLHttpRequestResponseType::Document;
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel));
|
||||
if (parseBody && httpChannel) {
|
||||
nsAutoCString method;
|
||||
httpChannel->GetRequestMethod(method);
|
||||
parseBody = !method.EqualsLiteral("HEAD");
|
||||
// Note: Main Fetch step 18 requires to ignore body for head/connect methods.
|
||||
bool parseBody = (mResponseType == XMLHttpRequestResponseType::_empty ||
|
||||
mResponseType == XMLHttpRequestResponseType::Document) &&
|
||||
!(mRequestMethod.EqualsLiteral("HEAD") ||
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue