mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-27 13:32:52 +00:00
LibWeb/Fetch: Append the Fetch metadata headers
This commit is contained in:
parent
e52f444329
commit
f5799f7d2c
Notes:
sideshowbarker
2024-07-17 21:26:19 +09:00
Author: https://github.com/jamierocks
Commit: f5799f7d2c
Pull-request: https://github.com/SerenityOS/serenity/pull/24164
Reviewed-by: https://github.com/kennethmyhra ✅
2 changed files with 23 additions and 1 deletions
|
@ -1355,7 +1355,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
|
|||
// 12. Append a request `Origin` header for httpRequest.
|
||||
http_request->add_origin_header();
|
||||
|
||||
// FIXME: 13. Append the Fetch metadata headers for httpRequest.
|
||||
// 13. Append the Fetch metadata headers for httpRequest.
|
||||
append_fetch_metadata_headers_for_request(*http_request);
|
||||
|
||||
// 14. If httpRequest’s header list does not contain `User-Agent`, then user agents should append
|
||||
// (`User-Agent`, default `User-Agent` value) to httpRequest’s header list.
|
||||
|
@ -2103,4 +2104,24 @@ void set_sec_fetch_user_header(Infrastructure::Request& request)
|
|||
request.header_list()->append(move(header));
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webappsec-fetch-metadata/#abstract-opdef-append-the-fetch-metadata-headers-for-a-request
|
||||
void append_fetch_metadata_headers_for_request(Infrastructure::Request& request)
|
||||
{
|
||||
// 1. If r’s url is not an potentially trustworthy URL, return.
|
||||
if (SecureContexts::is_url_potentially_trustworthy(request.url()) != SecureContexts::Trustworthiness::PotentiallyTrustworthy)
|
||||
return;
|
||||
|
||||
// 2. Set the Sec-Fetch-Dest header for r.
|
||||
set_sec_fetch_dest_header(request);
|
||||
|
||||
// 3. Set the Sec-Fetch-Mode header for r.
|
||||
set_sec_fetch_mode_header(request);
|
||||
|
||||
// 4. Set the Sec-Fetch-Site header for r.
|
||||
set_sec_fetch_site_header(request);
|
||||
|
||||
// 5. Set the Sec-Fetch-User header for r.
|
||||
set_sec_fetch_user_header(request);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue