summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-07-11 22:11:03 +0100
committerLinus Groh <mail@linusgroh.de>2022-07-14 00:42:26 +0100
commitdf3e25f1bba354016f820e6a1b53a0d766916d97 (patch)
tree84ed11b78f963caaafcb002a14bc0ce6447a08a3
parent7c2c9b6859a0be132e6851b5425b7da5c13698df (diff)
downloadserenity-df3e25f1bba354016f820e6a1b53a0d766916d97.zip
LibWeb: Add & use 'HTTP tab or space' from '2.2. HTTP' in the Fetch spec
-rw-r--r--Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP.h18
-rw-r--r--Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp5
2 files changed, 20 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP.h b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP.h
new file mode 100644
index 0000000000..ee0ed5c4e2
--- /dev/null
+++ b/Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Forward.h>
+#include <AK/StringView.h>
+
+namespace Web::Fetch {
+
+// https://fetch.spec.whatwg.org/#http-tab-or-space
+// An HTTP tab or space is U+0009 TAB or U+0020 SPACE.
+inline constexpr StringView HTTP_TAB_OR_SPACE = "\t "sv;
+
+}
diff --git a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
index 9a7b9f20bc..7245c85373 100644
--- a/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
+++ b/Userland/Libraries/LibWeb/XHR/XMLHttpRequest.cpp
@@ -24,6 +24,7 @@
#include <LibWeb/DOM/ExceptionOr.h>
#include <LibWeb/DOM/IDLEventListener.h>
#include <LibWeb/Fetch/AbstractOperations.h>
+#include <LibWeb/Fetch/Infrastructure/HTTP.h>
#include <LibWeb/HTML/EventHandler.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/Origin.h>
@@ -298,9 +299,7 @@ Optional<Vector<String>> XMLHttpRequest::get_decode_and_split(String const& head
}
// 3. Remove all HTTP tab or space from the start and end of value.
- // https://fetch.spec.whatwg.org/#http-tab-or-space
- // An HTTP tab or space is U+0009 TAB or U+0020 SPACE.
- auto trimmed_value = value.to_string().trim("\t "sv, TrimMode::Both);
+ auto trimmed_value = value.to_string().trim(Fetch::HTTP_TAB_OR_SPACE, TrimMode::Both);
// 4. Append value to values.
values.append(move(trimmed_value));