From 956106c6d8a40fd1678f442dbb168e2deddb63f5 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Mon, 27 May 2024 09:45:56 +0100 Subject: [PATCH] LibWeb: Add from_string function for request priority --- .../LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp | 11 +++++++++++ .../LibWeb/Fetch/Infrastructure/HTTP/Requests.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp index 19656b61508..bc80ce01127 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.cpp @@ -437,4 +437,15 @@ StringView request_mode_to_string(Request::Mode mode) VERIFY_NOT_REACHED(); } +Optional request_priority_from_string(StringView string) +{ + if (string.equals_ignoring_ascii_case("high"sv)) + return Request::Priority::High; + if (string.equals_ignoring_ascii_case("low"sv)) + return Request::Priority::Low; + if (string.equals_ignoring_ascii_case("auto"sv)) + return Request::Priority::Auto; + return {}; +} + } diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h index 9b49898664a..f002ce2b0ca 100644 --- a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h +++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP/Requests.h @@ -532,4 +532,6 @@ private: StringView request_destination_to_string(Request::Destination); StringView request_mode_to_string(Request::Mode); +Optional request_priority_from_string(StringView); + }