feat: [net] add "priority" option to net.request (#42628)

document the default value of priority option

Update the priority test to not use the httpbin.org as server

Fixed the lint errors

Fixed the build error
This commit is contained in:
zeeker999
2025-05-31 03:28:13 +08:00
committed by GitHub
parent cf6c662702
commit dc5efca0f6
5 changed files with 103 additions and 2 deletions

View File

@@ -638,6 +638,24 @@ gin::Handle<SimpleURLLoaderWrapper> SimpleURLLoaderWrapper::Create(
break;
}
if (std::string priority; opts.Get("priority", &priority)) {
static constexpr auto Lookup =
base::MakeFixedFlatMap<std::string_view, net::RequestPriority>({
{"throttled", net::THROTTLED},
{"idle", net::IDLE},
{"lowest", net::LOWEST},
{"low", net::LOW},
{"medium", net::MEDIUM},
{"highest", net::HIGHEST},
});
if (auto iter = Lookup.find(priority); iter != Lookup.end())
request->priority = iter->second;
}
if (bool priorityIncremental = request->priority_incremental;
opts.Get("priorityIncremental", &priorityIncremental)) {
request->priority_incremental = priorityIncremental;
}
const bool use_session_cookies =
opts.ValueOrDefault("useSessionCookies", false);
int options = network::mojom::kURLLoadOptionSniffMimeType;