Serenity Operating System
1/*
2 * Copyright (c) 2022-2023, Linus Groh <linusg@serenityos.org>
3 * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
4 *
5 * SPDX-License-Identifier: BSD-2-Clause
6 */
7
8#pragma once
9
10#include <AK/Forward.h>
11#include <AK/StringView.h>
12
13namespace Web::Fetch::Infrastructure {
14
15// https://fetch.spec.whatwg.org/#http-tab-or-space
16// An HTTP tab or space is U+0009 TAB or U+0020 SPACE.
17inline constexpr StringView HTTP_TAB_OR_SPACE = "\t "sv;
18
19// https://fetch.spec.whatwg.org/#http-whitespace
20// HTTP whitespace is U+000A LF, U+000D CR, or an HTTP tab or space.
21inline constexpr StringView HTTP_WHITESPACE = "\n\r\t "sv;
22
23// https://fetch.spec.whatwg.org/#http-newline-byte
24// An HTTP newline byte is 0x0A (LF) or 0x0D (CR).
25inline constexpr Array HTTP_NEWLINE_BYTES = {
26 0x0A, 0x0D
27};
28
29// https://fetch.spec.whatwg.org/#http-tab-or-space-byte
30// An HTTP tab or space byte is 0x09 (HT) or 0x20 (SP).
31inline constexpr Array HTTP_TAB_OR_SPACE_BYTES = {
32 0x09, 0x20
33};
34
35enum class HttpQuotedStringExtractValue {
36 No,
37 Yes,
38};
39
40ErrorOr<String> collect_an_http_quoted_string(GenericLexer& lexer, HttpQuotedStringExtractValue extract_value = HttpQuotedStringExtractValue::No);
41
42}