mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-02 04:20:28 +00:00
LibWeb/Fetch: Implement the "set the Sec-Fetch-Mode header" AO
This commit is contained in:
parent
f4af1833c1
commit
5eb46a5f01
Notes:
sideshowbarker
2024-07-16 23:38:54 +09:00
Author: https://github.com/jamierocks Commit: https://github.com/SerenityOS/serenity/commit/5eb46a5f01 Pull-request: https://github.com/SerenityOS/serenity/pull/24164 Reviewed-by: https://github.com/kennethmyhra ✅
2 changed files with 21 additions and 0 deletions
|
@ -2019,4 +2019,24 @@ void set_sec_fetch_dest_header(Infrastructure::Request& request)
|
|||
request.header_list()->append(move(header));
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webappsec-fetch-metadata/#abstract-opdef-set-dest
|
||||
void set_sec_fetch_mode_header(Infrastructure::Request& request)
|
||||
{
|
||||
// 1. Assert: r’s url is a potentially trustworthy URL.
|
||||
VERIFY(SecureContexts::is_url_potentially_trustworthy(request.url()) == SecureContexts::Trustworthiness::PotentiallyTrustworthy);
|
||||
|
||||
// 2. Let header be a Structured Header whose value is a token.
|
||||
// FIXME: This is handled below, as Serenity doesn't have APIs for RFC 8941.
|
||||
|
||||
// 3. Set header’s value to r’s mode.
|
||||
auto header_value = MUST(ByteBuffer::copy(Infrastructure::request_mode_to_string(request.mode()).bytes()));
|
||||
|
||||
// 4. Set a structured field value `Sec-Fetch-Mode`/header in r’s header list.
|
||||
auto header = Infrastructure::Header {
|
||||
.name = MUST(ByteBuffer::copy("Sec-Fetch-Mode"sv.bytes())),
|
||||
.value = move(header_value),
|
||||
};
|
||||
request.header_list()->append(move(header));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,4 +40,5 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_network_or_cache_fet
|
|||
WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> nonstandard_resource_loader_file_or_http_network_fetch(JS::Realm&, Infrastructure::FetchParams const&, IncludeCredentials include_credentials = IncludeCredentials::No, IsNewConnectionFetch is_new_connection_fetch = IsNewConnectionFetch::No);
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> cors_preflight_fetch(JS::Realm&, Infrastructure::Request&);
|
||||
void set_sec_fetch_dest_header(Infrastructure::Request&);
|
||||
void set_sec_fetch_mode_header(Infrastructure::Request&);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue