mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
LibWeb: Add & use 'HTTP tab or space' from '2.2. HTTP' in the Fetch spec
This commit is contained in:
parent
7c2c9b6859
commit
df3e25f1bb
2 changed files with 20 additions and 3 deletions
18
Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP.h
Normal file
18
Userland/Libraries/LibWeb/Fetch/Infrastructure/HTTP.h
Normal file
|
@ -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;
|
||||
|
||||
}
|
|
@ -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));
|
||||
|
|
Loading…
Add table
Reference in a new issue