1#ifndef SOURCEMETA_CORE_HTTP_SYNTAX_H_
2#define SOURCEMETA_CORE_HTTP_SYNTAX_H_
4#ifndef SOURCEMETA_CORE_HTTP_EXPORT
5#include <sourcemeta/core/http_export.h>
8#include <sourcemeta/core/text.h>
15namespace sourcemeta::core {
28inline auto http_is_ows(
const char character)
noexcept ->
bool {
29 return character ==
' ' || character ==
'\t';
79 return is_alphanum(character) || character ==
'-' || character ==
'.' ||
80 character ==
'_' || character ==
'~' || character ==
'+' ||
97 std::size_t position{0};
106 while (position < value.size()) {
107 if (value[position] !=
'=') {
133 for (
const auto character : value) {
159 std::string &sink) ->
bool {
160 for (
const auto character : value) {
161 const auto byte{
static_cast<unsigned char>(character)};
165 if (
byte != 0x09 && (
byte < 0x20 ||
byte == 0x7F)) {
171 for (
const auto character : value) {
172 if (character ==
'"' || character ==
'\\') {
173 sink.push_back(
'\\');
176 sink.push_back(character);
202 for (
const auto character : value) {
203 if (character ==
'\r' || character ==
'\n' || character ==
'\0') {
222 -> std::string_view {
223 while (!value.empty() &&
http_is_ows(value.front())) {
224 value.remove_prefix(1);
241 -> std::string_view {
242 while (!value.empty() &&
http_is_ows(value.back())) {
243 value.remove_suffix(1);
271SOURCEMETA_CORE_HTTP_EXPORT
273 const std::size_t position, std::string &storage,
274 std::string_view &value)
275 -> std::optional<std::size_t>;
auto http_trim_leading_ows(std::string_view value) noexcept -> std::string_view
Definition http_syntax.h:221
auto http_trim_trailing_ows(std::string_view value) noexcept -> std::string_view
Definition http_syntax.h:240
auto http_is_ows(const char character) noexcept -> bool
Definition http_syntax.h:28
auto http_is_token(const std::string_view value) noexcept -> bool
Definition http_syntax.h:128
auto http_is_b64token(const std::string_view value) noexcept -> bool
Definition http_syntax.h:96
auto http_field_line_has_forbidden_byte(const std::string_view value) noexcept -> bool
Definition http_syntax.h:196
auto http_is_b64token_char(const char character) noexcept -> bool
Definition http_syntax.h:78
SOURCEMETA_CORE_HTTP_EXPORT auto http_scan_quoted_string(const std::string_view input, const std::size_t position, std::string &storage, std::string_view &value) -> std::optional< std::size_t >
auto http_is_tchar(const char character) noexcept -> bool
Definition http_syntax.h:43
auto http_encode_quoted_string(const std::string_view value, std::string &sink) -> bool
Definition http_syntax.h:158
constexpr auto is_alphanum(const Character character) noexcept -> bool
Definition text.h:289