2022-07-11 22:11:03 +01:00
|
|
|
/*
|
2023-03-02 23:26:35 +00:00
|
|
|
* Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
|
2022-07-10 19:25:42 +02:00
|
|
|
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
|
2022-07-11 22:11:03 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Forward.h>
|
|
|
|
#include <AK/StringView.h>
|
2025-07-19 19:35:33 -07:00
|
|
|
#include <LibWeb/Export.h>
|
2022-07-11 22:11:03 +01:00
|
|
|
|
2022-07-17 23:52:02 +01:00
|
|
|
namespace Web::Fetch::Infrastructure {
|
2022-07-11 22:11:03 +01:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
2022-07-10 19:20:49 +02:00
|
|
|
// https://fetch.spec.whatwg.org/#http-whitespace
|
|
|
|
// HTTP whitespace is U+000A LF, U+000D CR, or an HTTP tab or space.
|
|
|
|
inline constexpr StringView HTTP_WHITESPACE = "\n\r\t "sv;
|
|
|
|
|
2022-07-11 21:42:14 +01:00
|
|
|
// https://fetch.spec.whatwg.org/#http-newline-byte
|
|
|
|
// An HTTP newline byte is 0x0A (LF) or 0x0D (CR).
|
|
|
|
inline constexpr Array HTTP_NEWLINE_BYTES = {
|
|
|
|
0x0A, 0x0D
|
|
|
|
};
|
|
|
|
|
|
|
|
// https://fetch.spec.whatwg.org/#http-tab-or-space-byte
|
|
|
|
// An HTTP tab or space byte is 0x09 (HT) or 0x20 (SP).
|
|
|
|
inline constexpr Array HTTP_TAB_OR_SPACE_BYTES = {
|
|
|
|
0x09, 0x20
|
|
|
|
};
|
|
|
|
|
2024-11-18 17:18:26 -06:00
|
|
|
constexpr bool is_http_tab_or_space(u32 const code_point)
|
|
|
|
{
|
|
|
|
return code_point == 0x09 || code_point == 0x20;
|
|
|
|
}
|
|
|
|
|
2024-12-24 19:11:33 -08:00
|
|
|
constexpr bool is_http_newline(u32 const code_point)
|
|
|
|
{
|
|
|
|
return code_point == 0x0A || code_point == 0x0D;
|
|
|
|
}
|
|
|
|
|
2022-07-10 19:25:42 +02:00
|
|
|
enum class HttpQuotedStringExtractValue {
|
|
|
|
No,
|
|
|
|
Yes,
|
|
|
|
};
|
|
|
|
|
2025-08-10 19:41:30 +02:00
|
|
|
enum class RedirectTaint {
|
|
|
|
SameOrigin,
|
|
|
|
SameSite,
|
|
|
|
CrossSite,
|
|
|
|
};
|
|
|
|
|
2025-07-19 19:35:33 -07:00
|
|
|
[[nodiscard]] WEB_API String collect_an_http_quoted_string(GenericLexer& lexer, HttpQuotedStringExtractValue extract_value = HttpQuotedStringExtractValue::No);
|
2022-07-10 19:25:42 +02:00
|
|
|
|
2022-07-11 22:11:03 +01:00
|
|
|
}
|