Bug 1933239 - Update HTTP Accept header when fetching a JSON module. r=dom-core,necko-reviewers,frontend-codestyle-reviewers,mossop,valentin,sefeng

According to https://fetch.spec.whatwg.org/#fetching

If the request's destination is "json", the Accept value in HTTP header
should be set to `application/json,*/*;q=0.5`.

Differential Revision: https://phabricator.services.mozilla.com/D235837
This commit is contained in:
Yoshi Cheng-Hao Huang
2025-02-10 14:18:48 +00:00
parent 10bbf8d4e9
commit 1b50922475
9 changed files with 69 additions and 6 deletions

View File

@@ -885,10 +885,8 @@ nsresult ScriptLoader::PrepareHttpRequestAndInitiatorType(
nsresult rv = NS_OK;
if (httpChannel) {
// HTTP content negotation has little value in this context.
nsAutoCString acceptTypes("*/*");
rv = httpChannel->SetRequestHeader("Accept"_ns, acceptTypes, false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
// The 'Accept' HTTP header should be set in
// nsHttpHandler::AddStandardRequestHeaders.
nsCOMPtr<nsIReferrerInfo> referrerInfo =
new ReferrerInfo(aRequest->mReferrer, aRequest->ReferrerPolicy());