mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibHTTP+LibWeb+RequestServer: Move Fetch's HTTP header infra to LibHTTP
The end goal here is for LibHTTP to be the home of our RFC 9111 (HTTP caching) implementation. We currently have one implementation in LibWeb for our in-memory cache and another in RequestServer for our disk cache. The implementations both largely revolve around interacting with HTTP headers. But in LibWeb, we are using Fetch's header infra, and in RS we are using are home-grown header infra from LibHTTP. So to give these a common denominator, this patch replaces the LibHTTP implementation with Fetch's infra. Our existing LibHTTP implementation was not particularly compliant with any spec, so this at least gives us a standards-based common implementation. This migration also required moving a handful of other Fetch AOs over to LibHTTP. (It turns out these AOs were all from the Fetch/Infra/HTTP folder, so perhaps it makes sense for LibHTTP to be the implementation of that entire set of facilities.)
This commit is contained in:
parent
3dce6766a3
commit
9375660b64
Notes:
github-actions[bot]
2025-11-27 13:58:52 +00:00
Author: https://github.com/trflynn89
Commit: 9375660b64
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6944
Reviewed-by: https://github.com/gmta ✅
78 changed files with 935 additions and 1017 deletions
|
|
@ -12,6 +12,8 @@
|
|||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibHTTP/HTTP.h>
|
||||
#include <LibHTTP/Header.h>
|
||||
#include <LibWeb/Fetch/Infrastructure/HTTP.h>
|
||||
#include <LibWeb/Infra/Strings.h>
|
||||
#include <LibWeb/MimeSniff/MimeType.h>
|
||||
|
|
@ -88,7 +90,7 @@ Optional<MimeType> MimeType::parse(StringView string)
|
|||
return OptionalNone {};
|
||||
|
||||
// 1. Remove any leading and trailing HTTP whitespace from input.
|
||||
auto trimmed_string = string.trim(Fetch::Infrastructure::HTTP_WHITESPACE, TrimMode::Both);
|
||||
auto trimmed_string = string.trim(HTTP::HTTP_WHITESPACE, TrimMode::Both);
|
||||
|
||||
// 2. Let position be a position variable for input, initially pointing at the start of input.
|
||||
GenericLexer lexer(trimmed_string);
|
||||
|
|
@ -111,7 +113,7 @@ Optional<MimeType> MimeType::parse(StringView string)
|
|||
auto subtype = lexer.consume_until(';');
|
||||
|
||||
// 8. Remove any trailing HTTP whitespace from subtype.
|
||||
subtype = subtype.trim(Fetch::Infrastructure::HTTP_WHITESPACE, TrimMode::Right);
|
||||
subtype = subtype.trim(HTTP::HTTP_WHITESPACE, TrimMode::Right);
|
||||
|
||||
// 9. If subtype is the empty string or does not solely contain HTTP token code points, then return failure.
|
||||
if (subtype.is_empty() || !contains_only_http_token_code_points(subtype))
|
||||
|
|
@ -126,7 +128,7 @@ Optional<MimeType> MimeType::parse(StringView string)
|
|||
lexer.ignore(1);
|
||||
|
||||
// 2. Collect a sequence of code points that are HTTP whitespace from input given position.
|
||||
lexer.ignore_while(is_any_of(Fetch::Infrastructure::HTTP_WHITESPACE));
|
||||
lexer.ignore_while(is_any_of(HTTP::HTTP_WHITESPACE));
|
||||
|
||||
// 3. Let parameterName be the result of collecting a sequence of code points that are not U+003B (;) or U+003D (=) from input, given position.
|
||||
auto parameter_name_view = lexer.consume_until([](char ch) {
|
||||
|
|
@ -157,7 +159,7 @@ Optional<MimeType> MimeType::parse(StringView string)
|
|||
// 8. If the code point at position within input is U+0022 ("), then:
|
||||
if (lexer.peek() == '"') {
|
||||
// 1. Set parameterValue to the result of collecting an HTTP quoted string from input, given position and the extract-value flag.
|
||||
parameter_value = Fetch::Infrastructure::collect_an_http_quoted_string(lexer, Fetch::Infrastructure::HttpQuotedStringExtractValue::Yes);
|
||||
parameter_value = HTTP::collect_an_http_quoted_string(lexer, HTTP::HttpQuotedStringExtractValue::Yes);
|
||||
|
||||
// 2. Collect a sequence of code points that are not U+003B (;) from input, given position.
|
||||
lexer.ignore_until(';');
|
||||
|
|
@ -169,7 +171,7 @@ Optional<MimeType> MimeType::parse(StringView string)
|
|||
parameter_value = String::from_utf8_without_validation(lexer.consume_until(';').bytes());
|
||||
|
||||
// 2. Remove any trailing HTTP whitespace from parameterValue.
|
||||
parameter_value = MUST(parameter_value.trim(Fetch::Infrastructure::HTTP_WHITESPACE, TrimMode::Right));
|
||||
parameter_value = MUST(parameter_value.trim(HTTP::HTTP_WHITESPACE, TrimMode::Right));
|
||||
|
||||
// 3. If parameterValue is the empty string, then continue.
|
||||
if (parameter_value.is_empty())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue