зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1341678 P1 Make Request::Constructor() expect over-writing a copied body with an initializer. r=asuth
This commit is contained in:
Родитель
25abcb5596
Коммит
895f116b72
|
@ -277,7 +277,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
const RequestOrUSVString& aInput,
|
||||
const RequestInit& aInit, ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> temporaryBody;
|
||||
bool hasCopiedBody = false;
|
||||
RefPtr<InternalRequest> request;
|
||||
|
||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
@ -290,8 +290,10 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The body will be copied when GetRequestConstructorCopy() is executed.
|
||||
if (body) {
|
||||
temporaryBody = body;
|
||||
hasCopiedBody = true;
|
||||
}
|
||||
|
||||
request = inputReq->GetInternalRequest();
|
||||
|
@ -535,7 +537,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
}
|
||||
|
||||
if ((aInit.mBody.WasPassed() && !aInit.mBody.Value().IsNull()) ||
|
||||
temporaryBody) {
|
||||
hasCopiedBody) {
|
||||
// HEAD and GET are not allowed to have a body.
|
||||
nsAutoCString method;
|
||||
request->GetMethod(method);
|
||||
|
@ -561,7 +563,7 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
temporaryBody = stream;
|
||||
nsCOMPtr<nsIInputStream> temporaryBody = stream;
|
||||
|
||||
if (!contentTypeWithCharset.IsVoid() &&
|
||||
!requestHeaders->Has(NS_LITERAL_CSTRING("Content-Type"), aRv)) {
|
||||
|
@ -574,6 +576,11 @@ Request::Constructor(const GlobalObject& aGlobal,
|
|||
}
|
||||
|
||||
request->ClearCreatedByFetchEvent();
|
||||
|
||||
if (hasCopiedBody) {
|
||||
request->SetBody(nullptr);
|
||||
}
|
||||
|
||||
request->SetBody(temporaryBody);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче