mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Store HTTP methods and headers as ByteString
The spec declares these as a byte sequence, which we then implemented as a ByteBuffer. This has become pretty awkward to deal with, as evidenced by the plethora of `MUST(ByteBuffer::copy(...))` and `.bytes()` calls everywhere inside Fetch. We would then treat the bytes as a string anyways by wrapping them in StringView everywhere. We now store these as a ByteString. This is more comfortable to deal with, and we no longer need to continually copy underlying storage (as ByteString is ref-counted). This work is largely preparatory for an upcoming HTTP header refactor.
This commit is contained in:
parent
ed27eea091
commit
f675cfe90f
Notes:
github-actions[bot]
2025-11-26 14:16:12 +00:00
Author: https://github.com/trflynn89
Commit: f675cfe90f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6933
28 changed files with 480 additions and 651 deletions
|
|
@ -22,13 +22,13 @@ namespace Web::ReferrerPolicy {
|
|||
ReferrerPolicy parse_a_referrer_policy_from_a_referrer_policy_header(Fetch::Infrastructure::Response const& response)
|
||||
{
|
||||
// 1. Let policy-tokens be the result of extracting header list values given `Referrer-Policy` and response’s header list.
|
||||
auto policy_tokens_or_failure = response.header_list()->extract_header_list_values("Referrer-Policy"sv.bytes());
|
||||
auto policy_tokens_or_failure = response.header_list()->extract_header_list_values("Referrer-Policy"sv);
|
||||
|
||||
// 2. Let policy be the empty string.
|
||||
auto policy = ReferrerPolicy::EmptyString;
|
||||
|
||||
// 3. For each token in policy-tokens, if token is a referrer policy and token is not the empty string, then set policy to token.
|
||||
if (auto const* policy_tokens = policy_tokens_or_failure.get_pointer<Vector<ByteBuffer>>()) {
|
||||
if (auto const* policy_tokens = policy_tokens_or_failure.get_pointer<Vector<ByteString>>()) {
|
||||
for (auto const& token : *policy_tokens) {
|
||||
auto referrer_policy = from_string(token);
|
||||
if (referrer_policy.has_value() && referrer_policy.value() != ReferrerPolicy::EmptyString)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue