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';
87 const auto byte{
static_cast<unsigned char>(character)};
88 return byte == 0x09 || (
byte >= 0x20 &&
byte != 0x7F);
104 return is_alphanum(character) || character ==
'-' || character ==
'.' ||
105 character ==
'_' || character ==
'~' || character ==
'+' ||
122 std::size_t position{0};
131 while (position < value.size()) {
132 if (value[position] !=
'=') {
158 for (
const auto character : value) {
184 std::string &sink) ->
bool {
188 for (
const auto character : value) {
195 for (
const auto character : value) {
196 if (character ==
'"' || character ==
'\\') {
197 sink.push_back(
'\\');
200 sink.push_back(character);
226 for (
const auto character : value) {
227 if (character ==
'\r' || character ==
'\n' || character ==
'\0') {
246 -> std::string_view {
247 while (!value.empty() &&
http_is_ows(value.front())) {
248 value.remove_prefix(1);
265 -> std::string_view {
266 while (!value.empty() &&
http_is_ows(value.back())) {
267 value.remove_suffix(1);
295SOURCEMETA_CORE_HTTP_EXPORT
297 const std::size_t position, std::string &storage,
298 std::string_view &value)
299 -> std::optional<std::size_t>;
auto http_trim_leading_ows(std::string_view value) noexcept -> std::string_view
Definition http_syntax.h:245
auto http_trim_trailing_ows(std::string_view value) noexcept -> std::string_view
Definition http_syntax.h:264
auto http_is_field_octet(const char character) noexcept -> bool
Definition http_syntax.h:86
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:153
auto http_is_b64token(const std::string_view value) noexcept -> bool
Definition http_syntax.h:121
auto http_field_line_has_forbidden_byte(const std::string_view value) noexcept -> bool
Definition http_syntax.h:220
auto http_is_b64token_char(const char character) noexcept -> bool
Definition http_syntax.h:103
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:183
constexpr auto is_alphanum(const Character character) noexcept -> bool
Definition text.h:293