HTTP.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #pragma once
  8. #include <AK/Forward.h>
  9. #include <AK/StringView.h>
  10. namespace Web::Fetch::Infrastructure {
  11. // https://fetch.spec.whatwg.org/#http-tab-or-space
  12. // An HTTP tab or space is U+0009 TAB or U+0020 SPACE.
  13. inline constexpr StringView HTTP_TAB_OR_SPACE = "\t "sv;
  14. // https://fetch.spec.whatwg.org/#http-whitespace
  15. // HTTP whitespace is U+000A LF, U+000D CR, or an HTTP tab or space.
  16. inline constexpr StringView HTTP_WHITESPACE = "\n\r\t "sv;
  17. // https://fetch.spec.whatwg.org/#http-newline-byte
  18. // An HTTP newline byte is 0x0A (LF) or 0x0D (CR).
  19. inline constexpr Array HTTP_NEWLINE_BYTES = {
  20. 0x0A, 0x0D
  21. };
  22. // https://fetch.spec.whatwg.org/#http-tab-or-space-byte
  23. // An HTTP tab or space byte is 0x09 (HT) or 0x20 (SP).
  24. inline constexpr Array HTTP_TAB_OR_SPACE_BYTES = {
  25. 0x09, 0x20
  26. };
  27. enum class HttpQuotedStringExtractValue {
  28. No,
  29. Yes,
  30. };
  31. ErrorOr<String> collect_an_http_quoted_string(GenericLexer& lexer, HttpQuotedStringExtractValue extract_value = HttpQuotedStringExtractValue::No);
  32. }