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 + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +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 #include #include +#include #include #include #include @@ -298,9 +299,7 @@ Optional> 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));