Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
HTTP

An implementation of HTTP-protocol parsing, formatting, and validation primitives per RFC 9110. More...

Classes

struct  sourcemeta::core::HTTPCookie
struct  sourcemeta::core::HTTPAWSCredentials
class  sourcemeta::core::HTTPError
class  sourcemeta::core::HTTPStatusError
struct  sourcemeta::core::HTTPProblemDetails
struct  sourcemeta::core::HTTPStatus
struct  sourcemeta::core::HTTPResponse
class  sourcemeta::core::HTTPSystemBackendError
class  sourcemeta::core::HTTPSystemRequest

Enumerations

enum class  sourcemeta::core::HTTPContentEncoding : std::uint8_t { HTTPContentEncoding::Identity , HTTPContentEncoding::GZIP }
enum class  sourcemeta::core::HTTPCookieSameSite : std::uint8_t { HTTPCookieSameSite::Strict , HTTPCookieSameSite::Lax , HTTPCookieSameSite::None }
enum class  sourcemeta::core::HTTPMethod : std::uint8_t {
  HTTPMethod::GET , HTTPMethod::HEAD , HTTPMethod::POST , HTTPMethod::PUT ,
  HTTPMethod::DELETE , HTTPMethod::CONNECT , HTTPMethod::OPTIONS , HTTPMethod::TRACE ,
  HTTPMethod::PATCH
}

Functions

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_match_accept (const std::string_view accept_header, std::initializer_list< std::string_view > candidates) -> std::string_view
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_accept_includes_all (const std::string_view accept_header, std::initializer_list< std::string_view > media_types) noexcept -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_content_type_matches (const std::string_view content_type_header, const std::string_view media_type) noexcept -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_match_accept_language (const std::string_view accept_language_header, std::initializer_list< std::string_view > candidates) -> std::string_view
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_negotiate_encoding (const std::string_view accept_encoding_header, const HTTPContentEncoding server_preference) noexcept -> std::optional< HTTPContentEncoding >
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_from_date (const std::string_view value) noexcept -> std::optional< std::chrono::system_clock::time_point >
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_cache_control_max_age (const std::string_view cache_control) noexcept -> std::optional< std::chrono::seconds >
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_format_link (const HTTPLink &link, std::string &out) -> void
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_format_link (const HTTPLink &link) -> std::string
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_format_links (std::span< const HTTPLink > links, std::string &out) -> void
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_format_links (std::span< const HTTPLink > links) -> std::string
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_cookie_valid (const HTTPCookie &cookie) -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_serialize_cookie (const HTTPCookie &cookie, std::string &out) -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_serialize_cookie (const HTTPCookie &cookie) -> std::optional< std::string >
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_field_list_contains_any (const std::string_view header_value, std::initializer_list< std::string_view > tokens) noexcept -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_parse_bearer (const std::string_view authorization) noexcept -> std::string_view
auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_canonical_request (const std::string_view method, const std::string_view path, const std::string_view query, const std::span< const std::pair< std::string_view, std::string_view > > headers, const std::string_view payload_hash, const bool normalize=true) -> std::string
auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_signed_headers (const std::span< const std::pair< std::string_view, std::string_view > > headers) -> std::string
auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_credential_scope (const std::string_view date, const std::string_view region, const std::string_view service) -> std::string
auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_string_to_sign (const std::string_view amz_date, const std::string_view scope, const std::string_view canonical_request) -> std::string
auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_signing_key (const std::string_view secret, const std::string_view date, const std::string_view region, const std::string_view service) -> std::array< std::uint8_t, 32 >
auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_signature (const std::array< std::uint8_t, 32 > &signing_key, const std::string_view string_to_sign) -> std::string
auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_authorization (const std::string_view access_key_id, const std::string_view scope, const std::string_view signed_headers, const std::string_view signature) -> std::string
constexpr auto sourcemeta::core::http_is_status_line (const std::string_view line) noexcept -> bool
template<typename Buffer>
auto sourcemeta::core::http_accumulate_header_line (Buffer &buffer, const std::string_view line) -> void
template<typename Callback>
auto sourcemeta::core::http_parse_headers (const std::string_view input, Callback callback) -> void
template<typename Callback>
auto sourcemeta::core::http_parse_cookies (const std::string_view input, Callback callback) -> void
template<typename Container>
auto sourcemeta::core::http_parse_cookies (const std::string_view input, Container &cookies) -> void
template<typename Container>
auto sourcemeta::core::http_cookie_values (const std::string_view input, const std::string_view name, Container &values) -> void
template<typename Container>
auto sourcemeta::core::http_parse_headers (const std::string_view input, Container &headers) -> void
template<typename Headers>
auto sourcemeta::core::http_serialize_headers (const Headers &headers) -> std::string
template<typename Headers>
auto sourcemeta::core::http_header_find (const Headers &headers, const std::string_view name) -> std::optional< std::string_view >
constexpr auto sourcemeta::core::http_method_string (const HTTPMethod method) noexcept -> std::string_view
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_make_problem_details (const HTTPProblemDetails &problem) -> sourcemeta::core::JSON
constexpr auto sourcemeta::core::http_status_from_code (const std::uint16_t code) noexcept -> HTTPStatus
auto sourcemeta::core::http_is_ows (const char character) noexcept -> bool
auto sourcemeta::core::http_is_tchar (const char character) noexcept -> bool
auto sourcemeta::core::http_is_b64token_char (const char character) noexcept -> bool
auto sourcemeta::core::http_is_b64token (const std::string_view value) noexcept -> bool
auto sourcemeta::core::http_is_token (const std::string_view value) noexcept -> bool
auto sourcemeta::core::http_encode_quoted_string (const std::string_view value, std::string &sink) -> bool
auto sourcemeta::core::http_field_line_has_forbidden_byte (const std::string_view value) noexcept -> bool
auto sourcemeta::core::http_trim_leading_ows (std::string_view value) noexcept -> std::string_view
auto sourcemeta::core::http_trim_trailing_ows (std::string_view value) noexcept -> std::string_view
SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::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 >

Variables

constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_CONTINUE
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_SWITCHING_PROTOCOLS
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_PROCESSING
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_EARLY_HINTS
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_OK
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_CREATED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_ACCEPTED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_NO_CONTENT
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_RESET_CONTENT
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_PARTIAL_CONTENT
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_MULTI_STATUS
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_ALREADY_REPORTED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_IM_USED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_MULTIPLE_CHOICES
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_MOVED_PERMANENTLY
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_FOUND
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_SEE_OTHER
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_NOT_MODIFIED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_USE_PROXY
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_TEMPORARY_REDIRECT
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_PERMANENT_REDIRECT
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_BAD_REQUEST
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_UNAUTHORIZED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_PAYMENT_REQUIRED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_FORBIDDEN
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_NOT_FOUND
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_METHOD_NOT_ALLOWED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_NOT_ACCEPTABLE
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_REQUEST_TIMEOUT
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_CONFLICT
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_GONE
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_LENGTH_REQUIRED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_PRECONDITION_FAILED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_CONTENT_TOO_LARGE
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_URI_TOO_LONG
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_RANGE_NOT_SATISFIABLE
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_EXPECTATION_FAILED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_IM_A_TEAPOT
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_MISDIRECTED_REQUEST
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_UNPROCESSABLE_CONTENT
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_LOCKED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_FAILED_DEPENDENCY
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_TOO_EARLY
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_UPGRADE_REQUIRED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_PRECONDITION_REQUIRED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_TOO_MANY_REQUESTS
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_INTERNAL_SERVER_ERROR
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_NOT_IMPLEMENTED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_BAD_GATEWAY
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_SERVICE_UNAVAILABLE
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_GATEWAY_TIMEOUT
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_VARIANT_ALSO_NEGOTIATES
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_INSUFFICIENT_STORAGE
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_LOOP_DETECTED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_NOT_EXTENDED
constexpr HTTPStatus sourcemeta::core::HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED

Detailed Description

An implementation of HTTP-protocol parsing, formatting, and validation primitives per RFC 9110.

This functionality is included as follows:

#include <sourcemeta/core/http.h>

Class Documentation

◆ sourcemeta::core::HTTPLink

struct sourcemeta::core::HTTPLink

A typed RFC 8288 §3 link-value. The caller owns the backing storage for every field, must URI-escape target, and must ensure parameter values are valid quoted-string content.

Public Attributes

std::string_view target
 The link target reference.
std::string_view rel
 The link relation type.
std::span< const std::pair< std::string_view, std::string_view > > parameters {}
 The additional target attributes of the link.

◆ sourcemeta::core::HTTPCookie

struct sourcemeta::core::HTTPCookie

A cookie to serialise into an RFC 6265 §4.1 Set-Cookie response header value. The caller owns the backing storage for every field. A valid cookie has a name that is an RFC 9110 §5.6.2 token and a value made of RFC 6265 §4.1.1 cookie-octets. RFC 6265bis §5.7 requires a cookie with a same-site mode of none to also be secure.

Public Attributes

std::string_view name {}
 The cookie name.
std::string_view value {}
 The cookie value.
std::optional< std::string_view > path {}
 The path the cookie is scoped to.
std::optional< std::string_view > domain {}
 The host the cookie is scoped to.
std::optional< std::chrono::seconds > max_age {}
 The cookie lifetime.
bool http_only {false}
 Whether the cookie is withheld from scripts.
bool secure {false}
 Whether the cookie is only sent over secure channels.
std::optional< HTTPCookieSameSitesame_site {}
 The cross-site request policy for the cookie.

◆ sourcemeta::core::HTTPAWSCredentials

struct sourcemeta::core::HTTPAWSCredentials

The credentials used to sign a request with AWS Signature Version 4. The session token is left empty when using long-term credentials.

Public Attributes

std::string_view access_key_id
 The access key identifier.
std::string_view secret_access_key
 The secret access key.
std::string_view session_token
 The temporary session token used with short-term credentials.

◆ sourcemeta::core::HTTPError

class sourcemeta::core::HTTPError

An error that prevented obtaining a response, such as a connection failure, a name resolution failure, or a TLS failure. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"https://example.com", "Connection refused"};
assert(error.url() == "https://example.com");
auto method() const noexcept -> HTTPMethod
Get the request method that triggered the failure.
Definition http_error.h:47
auto url() const noexcept -> const std::string &
Get the request URL that triggered the failure.
Definition http_error.h:52
Definition http_error.h:39
@ GET
Transfer a current representation of the target resource.
Definition http_method.h:14
Inheritance diagram for sourcemeta::core::HTTPError:
sourcemeta::core::HTTPStatusError

Public Member Functions

 HTTPError (const HTTPMethod method, std::string url, const std::string &message)
 Construct an error from the request method, URL, and a message.
auto method () const noexcept -> HTTPMethod
 Get the request method that triggered the failure.
auto url () const noexcept -> const std::string &
 Get the request URL that triggered the failure.

◆ sourcemeta::core::HTTPStatusError

class sourcemeta::core::HTTPStatusError

An error for a response with an unsuccessful status code, owning a copy of the status data. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"https://example.com", sourcemeta::core::HTTP_STATUS_NOT_FOUND};
auto status() const noexcept -> HTTPStatus
Definition http_error.h:85
Definition http_error.h:74
constexpr HTTPStatus HTTP_STATUS_NOT_FOUND
Definition http_status.h:173
Inheritance diagram for sourcemeta::core::HTTPStatusError:
sourcemeta::core::HTTPError

Public Member Functions

 HTTPStatusError (const HTTPMethod method, std::string url, const HTTPStatus &status)
auto status () const noexcept -> HTTPStatus
Public Member Functions inherited from sourcemeta::core::HTTPError
 HTTPError (const HTTPMethod method, std::string url, const std::string &message)
 Construct an error from the request method, URL, and a message.
auto method () const noexcept -> HTTPMethod
 Get the request method that triggered the failure.
auto url () const noexcept -> const std::string &
 Get the request URL that triggered the failure.

Constructor & Destructor Documentation

◆ HTTPStatusError()

sourcemeta::core::HTTPStatusError::HTTPStatusError ( const HTTPMethod method,
std::string url,
const HTTPStatus & status )
inline

Construct an error from the request method, URL, and the unsuccessful response status

Member Function Documentation

◆ status()

auto sourcemeta::core::HTTPStatusError::status ( ) const -> HTTPStatus
inlinenodiscardnoexcept

Get the response status that triggered the failure. The contained views borrow from this error and stay valid for its lifetime

◆ sourcemeta::core::HTTPProblemDetails

struct sourcemeta::core::HTTPProblemDetails

Fields of an RFC 9457 §3.1 Problem Details object.

Public Attributes

HTTPStatus status
 The HTTP status code for this occurrence of the problem.
JSON::StringView type {"about:blank"}
 The identifier for the problem type.
JSON::StringView title {}
 The short human-readable summary of the problem type.
JSON::StringView detail {}
 The human-readable explanation specific to this occurrence.
JSON::StringView instance {}
 The identifier for this specific occurrence of the problem.

◆ sourcemeta::core::HTTPStatus

struct sourcemeta::core::HTTPStatus

A typed HTTP status code per RFC 9110 §15. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
std::uint16_t code
The numeric status code.
Definition http_status.h:22
std::string_view wire
The status code and reason phrase in their wire form.
Definition http_status.h:26
std::string_view phrase
The reason phrase.
Definition http_status.h:24
constexpr HTTPStatus HTTP_STATUS_OK
Definition http_status.h:55

Public Attributes

std::uint16_t code
 The numeric status code.
std::string_view phrase
 The reason phrase.
std::string_view wire
 The status code and reason phrase in their wire form.

◆ sourcemeta::core::HTTPResponse

struct sourcemeta::core::HTTPResponse

The result of performing a request against a system HTTP backend. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
sourcemeta::core::HTTPSystemRequest request{"https://example.com"};
const auto response{request.send()};
assert(response.status == sourcemeta::core::HTTP_STATUS_OK);
auto send() const -> HTTPResponse
Definition http_system.h:117

Public Attributes

HTTPStatus status {}
 The response status code.
std::vector< std::pair< std::string, std::string > > headers
std::string body
 The response body, owned by this result.
std::string url
 The effective URL after any followed redirects.

Member Data Documentation

◆ headers

std::vector<std::pair<std::string, std::string> > sourcemeta::core::HTTPResponse::headers

The response headers, with names normalised to lowercase. Repeated headers are preserved as separate entries, though some backends fold them into a single comma-separated entry, which is lossy and incorrect for a Set-Cookie header that "cannot be combined into a single field value" (RFC 9110 §5.3)

◆ sourcemeta::core::HTTPSystemBackendError

class sourcemeta::core::HTTPSystemBackendError

An error that prevented loading the underlying system HTTP backend, such as a missing dynamically loaded library. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"Could not find the system cURL library", "SOURCEMETA_CORE_CURL_SO",
{"libcurl.so.4"}};
assert(error.variable() == "SOURCEMETA_CORE_CURL_SO");
auto variable() const noexcept -> const std::string &
Get the name of the environment variable that overrides the backend path.
Definition http_system.h:85
Definition http_system.h:75
Inheritance diagram for sourcemeta::core::HTTPSystemBackendError:

Public Member Functions

 HTTPSystemBackendError (const std::string &message, std::string variable, std::vector< std::string > paths)
auto variable () const noexcept -> const std::string &
 Get the name of the environment variable that overrides the backend path.
auto paths () const noexcept -> const std::vector< std::string > &
 Get the paths that were searched while looking for the backend.

Constructor & Destructor Documentation

◆ HTTPSystemBackendError()

sourcemeta::core::HTTPSystemBackendError::HTTPSystemBackendError ( const std::string & message,
std::string variable,
std::vector< std::string > paths )
inline

Construct an error from a message, the environment variable that overrides the backend path, and the paths that were searched

◆ sourcemeta::core::HTTPSystemRequest

class sourcemeta::core::HTTPSystemRequest

A simple cross-platform HTTP request that delegates to the system HTTP stack, NSURLSession on Apple platforms, WinHTTP on Windows, and cURL everywhere else. The request owns its data, configure it with the builder methods and perform it with send. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"https://example.com", sourcemeta::core::HTTPMethod::POST};
request.header("Accept", "application/json");
request.body("{}", "application/json");
const auto response{request.send()};
assert(response.status == sourcemeta::core::HTTP_STATUS_OK);
auto header(std::string name, std::string value) -> HTTPSystemRequest &
Definition http_system.h:150
auto body(std::string data, std::string content_type) -> HTTPSystemRequest &
Definition http_system.h:212
@ POST
Process the enclosed representation according to the resource semantics.
Definition http_method.h:18

Public Member Functions

 HTTPSystemRequest (std::string url, const HTTPMethod method=HTTPMethod::GET)
 Construct a request for the given URL and method.
auto method (const HTTPMethod method) -> HTTPSystemRequest &
 Set the request method.
auto header (std::string name, std::string value) -> HTTPSystemRequest &
auto header (std::string name, SecureString value) -> HTTPSystemRequest &
auto header (const std::string_view name) const -> std::optional< std::string_view >
auto headers () const noexcept -> const auto &
 Get the request headers configured so far, in the order they were added.
auto body (std::string data, std::string content_type) -> HTTPSystemRequest &
auto body (SecureString data, std::string content_type) -> HTTPSystemRequest &
auto follow_redirects (const bool value) -> HTTPSystemRequest &
 Set whether to follow redirects, on by default.
auto maximum_redirects (const std::size_t value) -> HTTPSystemRequest &
 Set the maximum number of redirects to follow, 20 by default.
auto timeout (const std::chrono::milliseconds value) -> HTTPSystemRequest &
 Set the total request timeout, 30 seconds by default.
auto connect_timeout (const std::chrono::milliseconds value) -> HTTPSystemRequest &
auto maximum_response_size (const std::size_t value) -> HTTPSystemRequest &
 Abort with an error if the response body exceeds this number of bytes.
auto sign_aws_sigv4 (const HTTPAWSCredentials &credentials, const std::string_view region, const std::string_view service, const std::chrono::system_clock::time_point moment=std::chrono::system_clock::now()) -> HTTPSystemRequest &
auto send () const -> HTTPResponse

Member Function Documentation

◆ body() [1/2]

auto sourcemeta::core::HTTPSystemRequest::body ( SecureString data,
std::string content_type ) -> HTTPSystemRequest &
inline

Set the request body from wiping storage, sent along with the given Content-Type header. The body is held in the wiping storage so a secret it carries, such as a client secret or PKCE code verifier, is never copied into an ordinary string. A content type carrying a carriage return, line feed, or NUL is refused, leaving the request unchanged

◆ body() [2/2]

auto sourcemeta::core::HTTPSystemRequest::body ( std::string data,
std::string content_type ) -> HTTPSystemRequest &
inline

Set the request body, sent along with the given Content-Type header. A content type carrying a carriage return, line feed, or NUL is refused, leaving the request unchanged

◆ connect_timeout()

auto sourcemeta::core::HTTPSystemRequest::connect_timeout ( const std::chrono::milliseconds value) -> HTTPSystemRequest &
inline

Set a best-effort timeout for establishing the connection, applied as each backend allows and falling back to the backend default when unset

◆ header() [1/3]

auto sourcemeta::core::HTTPSystemRequest::header ( const std::string_view name) const -> std::optional< std::string_view >
inlinenodiscard

Get the value of the first header with the given name, compared case insensitively, or no value when no such header was added. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
sourcemeta::core::HTTPSystemRequest request{"https://example.com"};
request.header("Accept", "application/json");
assert(request.header("accept").value() == "application/json");

◆ header() [2/3]

auto sourcemeta::core::HTTPSystemRequest::header ( std::string name,
SecureString value ) -> HTTPSystemRequest &
inline

Add a request header from wiping storage. The value is held in the wiping storage so a secret it carries, such as a client credential, is never retained in an ordinary string, and the transient serialisation a backend builds at send time is wiped

◆ header() [3/3]

auto sourcemeta::core::HTTPSystemRequest::header ( std::string name,
std::string value ) -> HTTPSystemRequest &
inline

Add a request header. Repeated names are permitted. A name or value carrying a carriage return, line feed, or NUL is refused, leaving the request unchanged

◆ send()

auto sourcemeta::core::HTTPSystemRequest::send ( ) const -> HTTPResponse
nodiscard

Perform the request. A failure to obtain a response is reported as an error, while unsuccessful status codes are returned on the result. This blocks the calling thread until the response arrives or a timeout elapses, so it must not run on an event loop or any other thread serving unrelated work.

◆ sign_aws_sigv4()

auto sourcemeta::core::HTTPSystemRequest::sign_aws_sigv4 ( const HTTPAWSCredentials & credentials,
const std::string_view region,
const std::string_view service,
const std::chrono::system_clock::time_point moment = std::chrono::system_clock::now() ) -> HTTPSystemRequest &

Sign this request with AWS Signature Version 4, stamping the x-amz-date, x-amz-content-sha256, and Authorization headers, plus x-amz-security-token when the credentials carry a session token. The path is normalised for every service except Amazon S3. The timestamp defaults to the current time. For example:

#include <sourcemeta/core/http.h>
"https://example.s3.amazonaws.com/key",
request.sign_aws_sigv4({.access_key_id = "AKIDEXAMPLE",
.secret_access_key = "secret"},
"us-east-1", "s3");
auto sign_aws_sigv4(const HTTPAWSCredentials &credentials, const std::string_view region, const std::string_view service, const std::chrono::system_clock::time_point moment=std::chrono::system_clock::now()) -> HTTPSystemRequest &

Enumeration Type Documentation

◆ HTTPContentEncoding

enum class sourcemeta::core::HTTPContentEncoding : std::uint8_t
strong

A content coding supported by this implementation.

Enumerator
Identity 

The identity coding that applies no transformation.

GZIP 

The gzip coding per RFC 9110 §8.4.1.3.

◆ HTTPCookieSameSite

enum class sourcemeta::core::HTTPCookieSameSite : std::uint8_t
strong

The SameSite attribute of a cookie per RFC 6265bis §5.2.

Enumerator
Strict 

The cookie is withheld from every cross-site request.

Lax 

The cookie is sent on top-level cross-site navigations only.

None 

The cookie is sent on every cross-site request.

◆ HTTPMethod

enum class sourcemeta::core::HTTPMethod : std::uint8_t
strong

A request method per RFC 9110 §9.3 and RFC 5789 §2.

Enumerator
GET 

Transfer a current representation of the target resource.

HEAD 

Identical to a retrieval but without transferring the response content.

POST 

Process the enclosed representation according to the resource semantics.

PUT 

Replace the target resource with the enclosed representation.

DELETE 

Remove the association between the target resource and its function.

CONNECT 

Establish a tunnel to the server identified by the target resource.

OPTIONS 

Describe the communication options available for the target resource.

TRACE 

Perform a message loop-back test along the path to the target resource.

PATCH 

Apply a partial modification to the target resource per RFC 5789 §2.

Function Documentation

◆ http_accept_includes_all()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_accept_includes_all ( const std::string_view accept_header,
std::initializer_list< std::string_view > media_types ) -> bool
noexcept

Test whether every media type is individually acceptable under an Accept header per RFC 9110 §12.5.1. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"text/html, application/json",
{"text/html", "application/json"}));
"text/html;q=0, application/json", {"text/html"}));
SOURCEMETA_CORE_HTTP_EXPORT auto http_accept_includes_all(const std::string_view accept_header, std::initializer_list< std::string_view > media_types) noexcept -> bool

◆ http_accumulate_header_line()

template<typename Buffer>
auto sourcemeta::core::http_accumulate_header_line ( Buffer & buffer,
const std::string_view line ) -> void
inline

Accumulate raw header lines into a buffer, retaining only the block of the most recent message, given that transparently following redirects or receiving interim responses produces one header block per message. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string>
std::string buffer;
"HTTP/1.1 301 Moved Permanently\r\n");
"HTTP/1.1 200 OK\r\n");
assert(buffer == "HTTP/1.1 200 OK\r\n");
auto http_accumulate_header_line(Buffer &buffer, const std::string_view line) -> void
Definition http_message.h:58

◆ http_aws_sigv4_authorization()

auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_authorization ( const std::string_view access_key_id,
const std::string_view scope,
const std::string_view signed_headers,
const std::string_view signature ) -> std::string

Assemble the AWS Signature Version 4 Authorization header value from an access key, credential scope, signed headers, and signature. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"AKIDEXAMPLE", "20150830/us-east-1/service/aws4_request",
"host;x-amz-date", "signature")};
assert(header.starts_with("AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/"));
auto SOURCEMETA_CORE_HTTP_EXPORT http_aws_sigv4_authorization(const std::string_view access_key_id, const std::string_view scope, const std::string_view signed_headers, const std::string_view signature) -> std::string

◆ http_aws_sigv4_canonical_request()

auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_canonical_request ( const std::string_view method,
const std::string_view path,
const std::string_view query,
const std::span< const std::pair< std::string_view, std::string_view > > headers,
const std::string_view payload_hash,
const bool normalize = true ) -> std::string

Compute the AWS Signature Version 4 canonical request from a request method, path, query, headers, and payload hash. Each path segment and query parameter is decoded and re-encoded into canonical form, so the path and query may be passed exactly as they appear in the request target. The path is optionally normalised by collapsing sequential slashes and removing dot segments, which every service except Amazon S3 requires. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string_view>
#include <utility>
#include <vector>
const std::vector<std::pair<std::string_view, std::string_view>> headers{
{"Host", "example.amazonaws.com"}, {"X-Amz-Date", "20150830T123600Z"}};
"GET", "/", "", headers,
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")};
assert(canonical.starts_with("GET\n/\n"));
auto SOURCEMETA_CORE_HTTP_EXPORT http_aws_sigv4_canonical_request(const std::string_view method, const std::string_view path, const std::string_view query, const std::span< const std::pair< std::string_view, std::string_view > > headers, const std::string_view payload_hash, const bool normalize=true) -> std::string
SOURCEMETA_CORE_IO_EXPORT auto canonical(const std::filesystem::path &path) -> std::filesystem::path

◆ http_aws_sigv4_credential_scope()

auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_credential_scope ( const std::string_view date,
const std::string_view region,
const std::string_view service ) -> std::string

Compute the AWS Signature Version 4 credential scope from a date, region, and service. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"20150830", "us-east-1", "service") ==
"20150830/us-east-1/service/aws4_request");
auto SOURCEMETA_CORE_HTTP_EXPORT http_aws_sigv4_credential_scope(const std::string_view date, const std::string_view region, const std::string_view service) -> std::string

◆ http_aws_sigv4_signature()

auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_signature ( const std::array< std::uint8_t, 32 > & signing_key,
const std::string_view string_to_sign ) -> std::string

Compute the AWS Signature Version 4 hex signature from a signing key and a string to sign. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY", "20150830", "us-east-1",
"service")};
assert(sourcemeta::core::http_aws_sigv4_signature(key, "string to sign")
.size() == 64);
auto SOURCEMETA_CORE_HTTP_EXPORT http_aws_sigv4_signing_key(const std::string_view secret, const std::string_view date, const std::string_view region, const std::string_view service) -> std::array< std::uint8_t, 32 >
auto SOURCEMETA_CORE_HTTP_EXPORT http_aws_sigv4_signature(const std::array< std::uint8_t, 32 > &signing_key, const std::string_view string_to_sign) -> std::string

◆ http_aws_sigv4_signed_headers()

auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_signed_headers ( const std::span< const std::pair< std::string_view, std::string_view > > headers) -> std::string

Compute the AWS Signature Version 4 signed headers list, the lowercased header names sorted and joined with a semicolon. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string_view>
#include <utility>
#include <vector>
const std::vector<std::pair<std::string_view, std::string_view>> headers{
{"Host", "example.amazonaws.com"}, {"X-Amz-Date", "20150830T123600Z"}};
"host;x-amz-date");
auto SOURCEMETA_CORE_HTTP_EXPORT http_aws_sigv4_signed_headers(const std::span< const std::pair< std::string_view, std::string_view > > headers) -> std::string

◆ http_aws_sigv4_signing_key()

auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_signing_key ( const std::string_view secret,
const std::string_view date,
const std::string_view region,
const std::string_view service ) -> std::array< std::uint8_t, 32 >

Derive the AWS Signature Version 4 signing key from a secret access key, date, region, and service. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY", "20150830", "us-east-1",
"service")};
assert(key.size() == 32);

◆ http_aws_sigv4_string_to_sign()

auto SOURCEMETA_CORE_HTTP_EXPORT sourcemeta::core::http_aws_sigv4_string_to_sign ( const std::string_view amz_date,
const std::string_view scope,
const std::string_view canonical_request ) -> std::string

Compute the AWS Signature Version 4 string to sign from a timestamp, a credential scope, and a canonical request. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"20150830T123600Z", "20150830/us-east-1/service/aws4_request",
"canonical request")};
assert(result.starts_with("AWS4-HMAC-SHA256\n20150830T123600Z\n"));
auto SOURCEMETA_CORE_HTTP_EXPORT http_aws_sigv4_string_to_sign(const std::string_view amz_date, const std::string_view scope, const std::string_view canonical_request) -> std::string

◆ http_cache_control_max_age()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_cache_control_max_age ( const std::string_view cache_control) -> std::optional< std::chrono::seconds >
noexcept

Read the max-age response directive from a Cache-Control header value per RFC 9111 §5.2.2.1. Returns an empty value when the directive is absent or malformed. A value larger than the cache can represent saturates to 2147483648 seconds as mandated by RFC 9111 §1.2.2. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <chrono>
"public, max-age=600")};
assert(max_age.has_value());
assert(max_age.value() == std::chrono::seconds{600});
SOURCEMETA_CORE_HTTP_EXPORT auto http_cache_control_max_age(const std::string_view cache_control) noexcept -> std::optional< std::chrono::seconds >

◆ http_content_type_matches()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_content_type_matches ( const std::string_view content_type_header,
const std::string_view media_type ) -> bool
noexcept

Test whether a Content-Type header denotes the given media type per RFC 9110 §8.3.1. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"application/json; charset=UTF-8", "application/json"));
"application/xml", "application/json"));
SOURCEMETA_CORE_HTTP_EXPORT auto http_content_type_matches(const std::string_view content_type_header, const std::string_view media_type) noexcept -> bool

◆ http_cookie_valid()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_cookie_valid ( const HTTPCookie & cookie) -> bool

Test whether a cookie can be serialised into a valid RFC 6265 §4.1 Set-Cookie header value: the name is a non-empty RFC 9110 §5.6.2 token, the value is made of RFC 6265 §4.1.1 cookie-octets, any path is made of RFC 6265bis av-octets, any domain is a valid RFC 1123 host name allowing an ignorable leading dot, a present max_age is not negative, per RFC 6265bis §5.7 a HTTPCookieSameSite::None cookie is also secure, and the RFC 6265bis §4.1.3 __Secure- and __Host- name prefixes carry their required attributes. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
assert(sourcemeta::core::http_cookie_valid({.name = "a", .value = "b"}));
assert(!sourcemeta::core::http_cookie_valid({.name = "a", .value = "b;c"}));
SOURCEMETA_CORE_HTTP_EXPORT auto http_cookie_valid(const HTTPCookie &cookie) -> bool

◆ http_cookie_values()

template<typename Container>
auto sourcemeta::core::http_cookie_values ( const std::string_view input,
const std::string_view name,
Container & values ) -> void
inline

Collect every value carried under the given cookie name, in the order the header presents them. A request may carry several cookies with one name, since a parent domain and the host itself can each set one and RFC 6265 §4.2.2 notes the server "cannot determine from the Cookie header alone [...] for which hosts the cookie is valid". That section also warns that servers "SHOULD NOT rely upon the order in which these cookies appear", so a caller verifying a signed cookie tries every value rather than any single one. Naming a cookie with the RFC 6265bis §4.1.3.2 __Host- prefix prevents the collision at the source.

The values are borrowed from input rather than copied, so a container of views must not outlive it, while an owning container may. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string_view>
#include <vector>
std::vector<std::string_view> values;
sourcemeta::core::http_cookie_values("session=abc; theme=dark; session=xyz",
"session", values);
assert(values.size() == 2);
assert(values.at(0) == "abc");
assert(values.at(1) == "xyz");
auto http_cookie_values(const std::string_view input, const std::string_view name, Container &values) -> void
Definition http_message.h:284

◆ http_encode_quoted_string()

auto sourcemeta::core::http_encode_quoted_string ( const std::string_view value,
std::string & sink ) -> bool
inline

Append a string to the sink as a quoted-string (RFC 9110 Section 5.6.4), wrapping it in double quotes and escaping any double quote or backslash, returning whether it was encodable. Nothing is appended when the string carries a byte no quoted-string admits, such as a control character, which keeps a value from injecting into a header. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string>
std::string sink;
assert(sink == R"("a\"b")");
auto http_encode_quoted_string(const std::string_view value, std::string &sink) -> bool
Definition http_syntax.h:158

◆ http_field_line_has_forbidden_byte()

auto sourcemeta::core::http_field_line_has_forbidden_byte ( const std::string_view value) -> bool
inlinenoexcept

Whether a field name or value carries a byte that must never appear on a field line, a carriage return, a line feed, or a NUL (RFC 9110 Section 5.5). For example:

#include <sourcemeta/core/http.h>
#include <cassert>
auto http_field_line_has_forbidden_byte(const std::string_view value) noexcept -> bool
Definition http_syntax.h:196

◆ http_field_list_contains_any()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_field_list_contains_any ( const std::string_view header_value,
std::initializer_list< std::string_view > tokens ) -> bool
noexcept

Test whether a comma-separated header value per RFC 9110 §5.6.1 lists any of the given tokens. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"\"abc\", W/\"def\", *", {"*"}));
"\"abc\", \"def\"", {"\"xyz\""}));
SOURCEMETA_CORE_HTTP_EXPORT auto http_field_list_contains_any(const std::string_view header_value, std::initializer_list< std::string_view > tokens) noexcept -> bool

◆ http_format_link() [1/2]

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_format_link ( const HTTPLink & link) -> std::string

Format an RFC 8288 §3 link-value. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
{.target = "https://example.com/schema.json", .rel = "describedby"})};
assert(value ==
"<https://example.com/schema.json>; rel=\"describedby\"");
SOURCEMETA_CORE_HTTP_EXPORT auto http_format_link(const HTTPLink &link, std::string &out) -> void

◆ http_format_link() [2/2]

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_format_link ( const HTTPLink & link,
std::string & out ) -> void

Append an RFC 8288 §3 link-value to out. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string>
std::string buffer{"prefix:"};
{.target = "/schema.json", .rel = "describedby"}, buffer);
assert(buffer == "prefix:</schema.json>; rel=\"describedby\"");

◆ http_format_links() [1/2]

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_format_links ( std::span< const HTTPLink > links) -> std::string

Format an RFC 8288 §3.5 comma-separated multi-link value. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
{.target = "/here", .rel = "self"},
{.target = "/next", .rel = "next"}};
const auto value{sourcemeta::core::http_format_links(links)};
assert(value ==
"</here>; rel=\"self\", </next>; rel=\"next\"");
SOURCEMETA_CORE_HTTP_EXPORT auto http_format_links(std::span< const HTTPLink > links, std::string &out) -> void

◆ http_format_links() [2/2]

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_format_links ( std::span< const HTTPLink > links,
std::string & out ) -> void

Append an RFC 8288 §3.5 comma-separated multi-link value to out. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string>
{.target = "/here", .rel = "self"},
{.target = "/next", .rel = "next"}};
std::string buffer;
assert(buffer ==
"</here>; rel=\"self\", </next>; rel=\"next\"");

◆ http_from_date()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_from_date ( const std::string_view value) -> std::optional< std::chrono::system_clock::time_point >
noexcept

Parse an HTTP-date string per RFC 9110 §5.6.7. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"Sun, 06 Nov 1994 08:49:37 GMT").has_value());
"Sunday, 06-Nov-94 08:49:37 GMT").has_value());
"Sun Nov 6 08:49:37 1994").has_value());
SOURCEMETA_CORE_HTTP_EXPORT auto http_from_date(const std::string_view value) noexcept -> std::optional< std::chrono::system_clock::time_point >

◆ http_header_find()

template<typename Headers>
auto sourcemeta::core::http_header_find ( const Headers & headers,
const std::string_view name ) -> std::optional< std::string_view >
inline

Find the value of the first header with the given lowercase name in any range of name and value pairs, returning no result when absent. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string>
#include <utility>
#include <vector>
const std::vector<std::pair<std::string, std::string>> headers{
{"server", "test"}};
assert(sourcemeta::core::http_header_find(headers, "server").has_value());
assert(!sourcemeta::core::http_header_find(headers, "date").has_value());
auto http_header_find(const Headers &headers, const std::string_view name) -> std::optional< std::string_view >
Definition http_message.h:444

◆ http_is_b64token()

auto sourcemeta::core::http_is_b64token ( const std::string_view value) -> bool
inlinenoexcept

Whether a string is a well-formed token68 (RFC 7235 Section 2.1) or b64token (RFC 6750 Section 2.1), at least one alphabet character followed by any "=" padding. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
auto http_is_b64token(const std::string_view value) noexcept -> bool
Definition http_syntax.h:96

◆ http_is_b64token_char()

auto sourcemeta::core::http_is_b64token_char ( const char character) -> bool
inlinenoexcept

Whether a character may appear in the alphabet of a token68 (RFC 7235 Section 2.1) or b64token (RFC 6750 Section 2.1) credential, before its padding. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
auto http_is_b64token_char(const char character) noexcept -> bool
Definition http_syntax.h:78

◆ http_is_ows()

auto sourcemeta::core::http_is_ows ( const char character) -> bool
inlinenoexcept

Whether a character is optional whitespace, a space or a horizontal tab (RFC 9110 Section 5.6.3). For example:

#include <sourcemeta/core/http.h>
#include <cassert>
auto http_is_ows(const char character) noexcept -> bool
Definition http_syntax.h:28

◆ http_is_status_line()

auto sourcemeta::core::http_is_status_line ( const std::string_view line) -> bool
inlineconstexprnoexcept

Test whether a raw line opens a message header block per RFC 9112 §4. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
assert(sourcemeta::core::http_is_status_line("HTTP/1.1 200 OK"));
assert(!sourcemeta::core::http_is_status_line("Content-Type: text/html"));
constexpr auto http_is_status_line(const std::string_view line) noexcept -> bool
Definition http_message.h:27

◆ http_is_tchar()

auto sourcemeta::core::http_is_tchar ( const char character) -> bool
inlinenoexcept

Whether a character is a token character (RFC 9110 Section 5.6.2), the set a bare header token draws from. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
auto http_is_tchar(const char character) noexcept -> bool
Definition http_syntax.h:43

◆ http_is_token()

auto sourcemeta::core::http_is_token ( const std::string_view value) -> bool
inlinenoexcept

Whether a string is a well-formed token (RFC 9110 Section 5.6.2), at least one token character and nothing else. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
assert(!sourcemeta::core::http_is_token("has space"));
auto http_is_token(const std::string_view value) noexcept -> bool
Definition http_syntax.h:128

◆ http_make_problem_details()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_make_problem_details ( const HTTPProblemDetails & problem) -> sourcemeta::core::JSON

Build an RFC 9457 §3.1 Problem Details JSON object. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
.type = "https://example.com/probs/not-found",
.detail = "The requested resource does not exist."})};
assert(body.at("status").to_integer() == 404);
assert(body.at("title").to_string() == "Not Found");
SOURCEMETA_CORE_HTTP_EXPORT auto http_make_problem_details(const HTTPProblemDetails &problem) -> sourcemeta::core::JSON

◆ http_match_accept()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_match_accept ( const std::string_view accept_header,
std::initializer_list< std::string_view > candidates ) -> std::string_view

Pick the best media-type candidate against an Accept header per RFC 9110 §12.5.1. Returns an empty value when no candidate is acceptable. The returned view borrows from candidates. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"text/html, application/json;q=0.9",
{"text/html", "application/json"})};
assert(best == "text/html");
SOURCEMETA_CORE_HTTP_EXPORT auto http_match_accept(const std::string_view accept_header, std::initializer_list< std::string_view > candidates) -> std::string_view

◆ http_match_accept_language()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_match_accept_language ( const std::string_view accept_language_header,
std::initializer_list< std::string_view > candidates ) -> std::string_view

Pick the best language-tag candidate against an Accept-Language header per RFC 9110 §12.5.4, which lets an implementation choose its matching scheme. This uses a q-aware Basic-Filtering-style scheme (RFC 4647 §3.3.1, the scheme RFC 9110 §12.5.4 points to) that also honors q=0 exclusions. Returns an empty value when no candidate is acceptable. The returned view borrows from candidates. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
"fr-CA;q=0.9, en;q=0.8", {"en", "fr"})};
assert(best == "fr");
SOURCEMETA_CORE_HTTP_EXPORT auto http_match_accept_language(const std::string_view accept_language_header, std::initializer_list< std::string_view > candidates) -> std::string_view

◆ http_method_string()

auto sourcemeta::core::http_method_string ( const HTTPMethod method) -> std::string_view
inlineconstexprnoexcept

Convert a request method into its case-sensitive token per RFC 9110 §9.1. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
constexpr auto http_method_string(const HTTPMethod method) noexcept -> std::string_view
Definition http_method.h:44

◆ http_negotiate_encoding()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_negotiate_encoding ( const std::string_view accept_encoding_header,
const HTTPContentEncoding server_preference ) -> std::optional< HTTPContentEncoding >
noexcept

Resolve a content coding against an Accept-Encoding header per RFC 9110 §12.5.3. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
assert(chosen.has_value());
SOURCEMETA_CORE_HTTP_EXPORT auto http_negotiate_encoding(const std::string_view accept_encoding_header, const HTTPContentEncoding server_preference) noexcept -> std::optional< HTTPContentEncoding >
@ GZIP
The gzip coding per RFC 9110 §8.4.1.3.
Definition http.h:46

◆ http_parse_bearer()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_parse_bearer ( const std::string_view authorization) -> std::string_view
noexcept

Extract the credential from an Authorization header that uses the Bearer scheme per RFC 6750 §2.1, matching the scheme case-insensitively per RFC 9110 §11.1 and tolerating optional whitespace around the token. Returns an empty view when the header is absent, uses another scheme, or does not carry a well-formed b64token credential. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
assert(sourcemeta::core::http_parse_bearer("Bearer abc123") == "abc123");
assert(sourcemeta::core::http_parse_bearer("Basic abc123").empty());
SOURCEMETA_CORE_HTTP_EXPORT auto http_parse_bearer(const std::string_view authorization) noexcept -> std::string_view

◆ http_parse_cookies() [1/2]

template<typename Callback>
auto sourcemeta::core::http_parse_cookies ( const std::string_view input,
Callback callback ) -> void
inline

Parse the value of an RFC 6265 §4.2 Cookie request header, given without the field name, into its cookie-pairs, invoking the callback once per pair with the name and value. A request cookie header carries only names and values, never attributes. Surrounding whitespace is trimmed, values are otherwise reported verbatim, and pairs that lack a = or have an empty name are skipped. Neither argument allocates, as both are borrowed from the input, so anything the callback keeps must not outlive it. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string_view>
std::size_t count{0};
"session=abc; theme=dark",
[&count](const std::string_view, const std::string_view) {
count += 1;
});
assert(count == 2);
auto http_parse_cookies(const std::string_view input, Callback callback) -> void
Definition http_message.h:193

A header may carry several cookies under one name, so a callback that assigns to a single variable keeps whichever happens to come last. Use http_cookie_values to look one up by name.

◆ http_parse_cookies() [2/2]

template<typename Container>
auto sourcemeta::core::http_parse_cookies ( const std::string_view input,
Container & cookies ) -> void
inline

Parse the value of an RFC 6265 §4.2 Cookie request header, given without the field name, into any container of name and value pairs. The names and values are borrowed from input rather than copied, so a container of views must not outlive it, while an owning container may. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string_view>
#include <utility>
#include <vector>
std::vector<std::pair<std::string_view, std::string_view>> cookies;
sourcemeta::core::http_parse_cookies("session=abc; theme=dark", cookies);
assert(cookies.size() == 2);
assert(cookies.at(0).first == "session");
assert(cookies.at(0).second == "abc");

◆ http_parse_headers() [1/2]

template<typename Callback>
auto sourcemeta::core::http_parse_headers ( const std::string_view input,
Callback callback ) -> void
inline

Parse the field lines of a raw message header block per RFC 9112 §5, skipping the start line and invoking the callback with each raw field name and its value with optional whitespace excluded. A continuation of the previous value through deprecated line folding is reported with an empty name. Malformed field lines are discarded. Neither argument allocates, as both are views into the input. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string_view>
"HTTP/1.1 200 OK\r\nServer: test\r\n\r\n",
[](const std::string_view name, const std::string_view value) {
assert(name == "Server");
assert(value == "test");
});
auto http_parse_headers(const std::string_view input, Callback callback) -> void
Definition http_message.h:89

◆ http_parse_headers() [2/2]

template<typename Container>
auto sourcemeta::core::http_parse_headers ( const std::string_view input,
Container & headers ) -> void
inline

Parse the field lines of a raw message header block, skipping the start line, into any container of name and value pairs, normalising names to lowercase given that RFC 9110 §5.1 mandates that "field names are case-insensitive", preserving repeated fields as separate entries, and joining deprecated line folding per RFC 9112 §5.2. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string>
#include <utility>
#include <vector>
std::vector<std::pair<std::string, std::string>> headers;
"HTTP/1.1 200 OK\r\nServer: test\r\n\r\n", headers);
assert(headers.size() == 1);
assert(headers.at(0).first == "server");
assert(headers.at(0).second == "test");

◆ http_scan_quoted_string()

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::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 >

Scan a quoted-string (RFC 9110 Section 5.6.4) whose opening double quote is at position in input, returning the position just past the closing quote, or no value when it is malformed. The unescaped content is written to value, borrowing from input when it carries no quoted-pair and appending to storage otherwise, whose capacity should be reserved up front so that earlier views into it stay valid. Control characters other than horizontal tab are rejected as a header-injection defense. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string>
#include <string_view>
std::string storage;
std::string_view value;
R"("hello")", 0, storage, value)};
assert(next.has_value());
assert(value == "hello");
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 >

◆ http_serialize_cookie() [1/2]

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_serialize_cookie ( const HTTPCookie & cookie) -> std::optional< std::string >

Serialise an RFC 6265 §4.1 Set-Cookie header value, returning no value when the cookie is not http_cookie_valid. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
{.name = "session", .value = "abc", .secure = true})};
assert(value == "session=abc; Secure");
SOURCEMETA_CORE_HTTP_EXPORT auto http_serialize_cookie(const HTTPCookie &cookie, std::string &out) -> bool

◆ http_serialize_cookie() [2/2]

SOURCEMETA_CORE_HTTP_EXPORT auto sourcemeta::core::http_serialize_cookie ( const HTTPCookie & cookie,
std::string & out ) -> bool

Append an RFC 6265 §4.1 Set-Cookie header value to out, returning true on success. When the cookie is not http_cookie_valid, out is left unchanged and this returns false. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string>
std::string buffer;
{.name = "session", .value = "abc", .http_only = true}, buffer)};
assert(ok);
assert(buffer == "session=abc; HttpOnly");

◆ http_serialize_headers()

template<typename Headers>
auto sourcemeta::core::http_serialize_headers ( const Headers & headers) -> std::string
inline

Serialise headers, given as any range of name and value pairs, into CRLF-delimited field lines per RFC 9112 §5. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
#include <string>
#include <utility>
#include <vector>
const std::vector<std::pair<std::string, std::string>> headers{
{"Accept", "application/json"}};
"Accept: application/json\r\n");
auto http_serialize_headers(const Headers &headers) -> std::string
Definition http_message.h:366

◆ http_status_from_code()

auto sourcemeta::core::http_status_from_code ( const std::uint16_t code) -> HTTPStatus
inlineconstexprnoexcept

Resolve a numeric status code into its registered status, with unknown codes resolving to an empty reason phrase. For example:

#include <sourcemeta/core/http.h>
#include <cassert>
assert(sourcemeta::core::http_status_from_code(599).phrase.empty());
constexpr auto http_status_from_code(const std::uint16_t code) noexcept -> HTTPStatus
Definition http_status.h:404

◆ http_trim_leading_ows()

auto sourcemeta::core::http_trim_leading_ows ( std::string_view value) -> std::string_view
inlinenoexcept

The view with any leading optional whitespace removed (RFC 9110 Section 5.6.3). For example:

#include <sourcemeta/core/http.h>
#include <cassert>
auto http_trim_leading_ows(std::string_view value) noexcept -> std::string_view
Definition http_syntax.h:221

◆ http_trim_trailing_ows()

auto sourcemeta::core::http_trim_trailing_ows ( std::string_view value) -> std::string_view
inlinenoexcept

The view with any trailing optional whitespace removed (RFC 9110 Section 5.6.3). For example:

#include <sourcemeta/core/http.h>
#include <cassert>
auto http_trim_trailing_ows(std::string_view value) noexcept -> std::string_view
Definition http_syntax.h:240

Variable Documentation

◆ HTTP_STATUS_ACCEPTED

HTTPStatus sourcemeta::core::HTTP_STATUS_ACCEPTED
inlineconstexpr
Initial value:
{
.code = 202, .phrase = "Accepted", .wire = "202 Accepted"}

RFC 9110 §15.3.3 (Successful).

◆ HTTP_STATUS_ALREADY_REPORTED

HTTPStatus sourcemeta::core::HTTP_STATUS_ALREADY_REPORTED
inlineconstexpr
Initial value:
{
.code = 208, .phrase = "Already Reported", .wire = "208 Already Reported"}

RFC 5842 §7.1 (WebDAV).

◆ HTTP_STATUS_BAD_GATEWAY

HTTPStatus sourcemeta::core::HTTP_STATUS_BAD_GATEWAY
inlineconstexpr
Initial value:
{
.code = 502, .phrase = "Bad Gateway", .wire = "502 Bad Gateway"}

RFC 9110 §15.6.3 (Server Error).

◆ HTTP_STATUS_BAD_REQUEST

HTTPStatus sourcemeta::core::HTTP_STATUS_BAD_REQUEST
inlineconstexpr
Initial value:
{
.code = 400, .phrase = "Bad Request", .wire = "400 Bad Request"}

RFC 9110 §15.5.1 (Client Error).

◆ HTTP_STATUS_CONFLICT

HTTPStatus sourcemeta::core::HTTP_STATUS_CONFLICT
inlineconstexpr
Initial value:
{
.code = 409, .phrase = "Conflict", .wire = "409 Conflict"}

RFC 9110 §15.5.10 (Client Error).

◆ HTTP_STATUS_CONTENT_TOO_LARGE

HTTPStatus sourcemeta::core::HTTP_STATUS_CONTENT_TOO_LARGE
inlineconstexpr
Initial value:
{
.code = 413,
.phrase = "Content Too Large",
.wire = "413 Content Too Large"}

RFC 9110 §15.5.14 (Client Error). RFC 9110 renamed this from "Payload Too Large" (RFC 7231) to "Content Too Large".

◆ HTTP_STATUS_CONTINUE

HTTPStatus sourcemeta::core::HTTP_STATUS_CONTINUE
inlineconstexpr
Initial value:
{
.code = 100, .phrase = "Continue", .wire = "100 Continue"}

RFC 9110 §15.2.1 (Informational).

◆ HTTP_STATUS_CREATED

HTTPStatus sourcemeta::core::HTTP_STATUS_CREATED
inlineconstexpr
Initial value:
{
.code = 201, .phrase = "Created", .wire = "201 Created"}

RFC 9110 §15.3.2 (Successful).

◆ HTTP_STATUS_EARLY_HINTS

HTTPStatus sourcemeta::core::HTTP_STATUS_EARLY_HINTS
inlineconstexpr
Initial value:
{
.code = 103, .phrase = "Early Hints", .wire = "103 Early Hints"}

RFC 8297 §2.

◆ HTTP_STATUS_EXPECTATION_FAILED

HTTPStatus sourcemeta::core::HTTP_STATUS_EXPECTATION_FAILED
inlineconstexpr
Initial value:
{
.code = 417,
.phrase = "Expectation Failed",
.wire = "417 Expectation Failed"}

RFC 9110 §15.5.18 (Client Error).

◆ HTTP_STATUS_FAILED_DEPENDENCY

HTTPStatus sourcemeta::core::HTTP_STATUS_FAILED_DEPENDENCY
inlineconstexpr
Initial value:
{
.code = 424,
.phrase = "Failed Dependency",
.wire = "424 Failed Dependency"}

RFC 4918 §11.4 (WebDAV).

◆ HTTP_STATUS_FORBIDDEN

HTTPStatus sourcemeta::core::HTTP_STATUS_FORBIDDEN
inlineconstexpr
Initial value:
{
.code = 403, .phrase = "Forbidden", .wire = "403 Forbidden"}

RFC 9110 §15.5.4 (Client Error).

◆ HTTP_STATUS_FOUND

HTTPStatus sourcemeta::core::HTTP_STATUS_FOUND
inlineconstexpr
Initial value:
{
.code = 302, .phrase = "Found", .wire = "302 Found"}

RFC 9110 §15.4.3 (Redirection).

◆ HTTP_STATUS_GATEWAY_TIMEOUT

HTTPStatus sourcemeta::core::HTTP_STATUS_GATEWAY_TIMEOUT
inlineconstexpr
Initial value:
{
.code = 504, .phrase = "Gateway Timeout", .wire = "504 Gateway Timeout"}

RFC 9110 §15.6.5 (Server Error).

◆ HTTP_STATUS_GONE

HTTPStatus sourcemeta::core::HTTP_STATUS_GONE
inlineconstexpr
Initial value:
{
.code = 410, .phrase = "Gone", .wire = "410 Gone"}

RFC 9110 §15.5.11 (Client Error).

◆ HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED

HTTPStatus sourcemeta::core::HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED
inlineconstexpr
Initial value:
{
.code = 505,
.phrase = "HTTP Version Not Supported",
.wire = "505 HTTP Version Not Supported"}

RFC 9110 §15.6.6 (Server Error).

◆ HTTP_STATUS_IM_A_TEAPOT

HTTPStatus sourcemeta::core::HTTP_STATUS_IM_A_TEAPOT
inlineconstexpr
Initial value:
{
.code = 418, .phrase = "I'm a Teapot", .wire = "418 I'm a Teapot"}

RFC 2324 §2.3.2 (HTCPCP).

◆ HTTP_STATUS_IM_USED

HTTPStatus sourcemeta::core::HTTP_STATUS_IM_USED
inlineconstexpr
Initial value:
{
.code = 226, .phrase = "IM Used", .wire = "226 IM Used"}

RFC 3229 §10.4.1 (HTTP Delta Encoding).

◆ HTTP_STATUS_INSUFFICIENT_STORAGE

HTTPStatus sourcemeta::core::HTTP_STATUS_INSUFFICIENT_STORAGE
inlineconstexpr
Initial value:
{
.code = 507,
.phrase = "Insufficient Storage",
.wire = "507 Insufficient Storage"}

RFC 4918 §11.5 (WebDAV).

◆ HTTP_STATUS_INTERNAL_SERVER_ERROR

HTTPStatus sourcemeta::core::HTTP_STATUS_INTERNAL_SERVER_ERROR
inlineconstexpr
Initial value:
{
.code = 500,
.phrase = "Internal Server Error",
.wire = "500 Internal Server Error"}

RFC 9110 §15.6.1 (Server Error).

◆ HTTP_STATUS_LENGTH_REQUIRED

HTTPStatus sourcemeta::core::HTTP_STATUS_LENGTH_REQUIRED
inlineconstexpr
Initial value:
{
.code = 411, .phrase = "Length Required", .wire = "411 Length Required"}

RFC 9110 §15.5.12 (Client Error).

◆ HTTP_STATUS_LOCKED

HTTPStatus sourcemeta::core::HTTP_STATUS_LOCKED
inlineconstexpr
Initial value:
{
.code = 423, .phrase = "Locked", .wire = "423 Locked"}

RFC 4918 §11.3 (WebDAV).

◆ HTTP_STATUS_LOOP_DETECTED

HTTPStatus sourcemeta::core::HTTP_STATUS_LOOP_DETECTED
inlineconstexpr
Initial value:
{
.code = 508, .phrase = "Loop Detected", .wire = "508 Loop Detected"}

RFC 5842 §7.2 (WebDAV).

◆ HTTP_STATUS_METHOD_NOT_ALLOWED

HTTPStatus sourcemeta::core::HTTP_STATUS_METHOD_NOT_ALLOWED
inlineconstexpr
Initial value:
{
.code = 405,
.phrase = "Method Not Allowed",
.wire = "405 Method Not Allowed"}

RFC 9110 §15.5.6 (Client Error).

◆ HTTP_STATUS_MISDIRECTED_REQUEST

HTTPStatus sourcemeta::core::HTTP_STATUS_MISDIRECTED_REQUEST
inlineconstexpr
Initial value:
{
.code = 421,
.phrase = "Misdirected Request",
.wire = "421 Misdirected Request"}

RFC 9110 §15.5.20 (Client Error).

◆ HTTP_STATUS_MOVED_PERMANENTLY

HTTPStatus sourcemeta::core::HTTP_STATUS_MOVED_PERMANENTLY
inlineconstexpr
Initial value:
{
.code = 301,
.phrase = "Moved Permanently",
.wire = "301 Moved Permanently"}

RFC 9110 §15.4.2 (Redirection).

◆ HTTP_STATUS_MULTI_STATUS

HTTPStatus sourcemeta::core::HTTP_STATUS_MULTI_STATUS
inlineconstexpr
Initial value:
{
.code = 207, .phrase = "Multi-Status", .wire = "207 Multi-Status"}

RFC 4918 §11.1 (WebDAV).

◆ HTTP_STATUS_MULTIPLE_CHOICES

HTTPStatus sourcemeta::core::HTTP_STATUS_MULTIPLE_CHOICES
inlineconstexpr
Initial value:
{
.code = 300, .phrase = "Multiple Choices", .wire = "300 Multiple Choices"}

RFC 9110 §15.4.1 (Redirection).

◆ HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED

HTTPStatus sourcemeta::core::HTTP_STATUS_NETWORK_AUTHENTICATION_REQUIRED
inlineconstexpr
Initial value:
{
.code = 511,
.phrase = "Network Authentication Required",
.wire = "511 Network Authentication Required"}

RFC 6585 §6.

◆ HTTP_STATUS_NO_CONTENT

HTTPStatus sourcemeta::core::HTTP_STATUS_NO_CONTENT
inlineconstexpr
Initial value:
{
.code = 204, .phrase = "No Content", .wire = "204 No Content"}

RFC 9110 §15.3.5 (Successful).

◆ HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION

HTTPStatus sourcemeta::core::HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION
inlineconstexpr
Initial value:
{
.code = 203,
.phrase = "Non-Authoritative Information",
.wire = "203 Non-Authoritative Information"}

RFC 9110 §15.3.4 (Successful).

◆ HTTP_STATUS_NOT_ACCEPTABLE

HTTPStatus sourcemeta::core::HTTP_STATUS_NOT_ACCEPTABLE
inlineconstexpr
Initial value:
{
.code = 406, .phrase = "Not Acceptable", .wire = "406 Not Acceptable"}

RFC 9110 §15.5.7 (Client Error).

◆ HTTP_STATUS_NOT_EXTENDED

HTTPStatus sourcemeta::core::HTTP_STATUS_NOT_EXTENDED
inlineconstexpr
Initial value:
{
.code = 510, .phrase = "Not Extended", .wire = "510 Not Extended"}

RFC 2774 §7.

◆ HTTP_STATUS_NOT_FOUND

HTTPStatus sourcemeta::core::HTTP_STATUS_NOT_FOUND
inlineconstexpr
Initial value:
{
.code = 404, .phrase = "Not Found", .wire = "404 Not Found"}

RFC 9110 §15.5.5 (Client Error).

◆ HTTP_STATUS_NOT_IMPLEMENTED

HTTPStatus sourcemeta::core::HTTP_STATUS_NOT_IMPLEMENTED
inlineconstexpr
Initial value:
{
.code = 501, .phrase = "Not Implemented", .wire = "501 Not Implemented"}

RFC 9110 §15.6.2 (Server Error).

◆ HTTP_STATUS_NOT_MODIFIED

HTTPStatus sourcemeta::core::HTTP_STATUS_NOT_MODIFIED
inlineconstexpr
Initial value:
{
.code = 304, .phrase = "Not Modified", .wire = "304 Not Modified"}

RFC 9110 §15.4.5 (Redirection).

◆ HTTP_STATUS_OK

HTTPStatus sourcemeta::core::HTTP_STATUS_OK
inlineconstexpr
Initial value:
{
.code = 200, .phrase = "OK", .wire = "200 OK"}

RFC 9110 §15.3.1 (Successful).

◆ HTTP_STATUS_PARTIAL_CONTENT

HTTPStatus sourcemeta::core::HTTP_STATUS_PARTIAL_CONTENT
inlineconstexpr
Initial value:
{
.code = 206, .phrase = "Partial Content", .wire = "206 Partial Content"}

RFC 9110 §15.3.7 (Successful).

◆ HTTP_STATUS_PAYMENT_REQUIRED

HTTPStatus sourcemeta::core::HTTP_STATUS_PAYMENT_REQUIRED
inlineconstexpr
Initial value:
{
.code = 402, .phrase = "Payment Required", .wire = "402 Payment Required"}

RFC 9110 §15.5.3 (Client Error).

◆ HTTP_STATUS_PERMANENT_REDIRECT

HTTPStatus sourcemeta::core::HTTP_STATUS_PERMANENT_REDIRECT
inlineconstexpr
Initial value:
{
.code = 308,
.phrase = "Permanent Redirect",
.wire = "308 Permanent Redirect"}

RFC 9110 §15.4.9 (Redirection).

◆ HTTP_STATUS_PRECONDITION_FAILED

HTTPStatus sourcemeta::core::HTTP_STATUS_PRECONDITION_FAILED
inlineconstexpr
Initial value:
{
.code = 412,
.phrase = "Precondition Failed",
.wire = "412 Precondition Failed"}

RFC 9110 §15.5.13 (Client Error).

◆ HTTP_STATUS_PRECONDITION_REQUIRED

HTTPStatus sourcemeta::core::HTTP_STATUS_PRECONDITION_REQUIRED
inlineconstexpr
Initial value:
{
.code = 428,
.phrase = "Precondition Required",
.wire = "428 Precondition Required"}

RFC 6585 §3.

◆ HTTP_STATUS_PROCESSING

HTTPStatus sourcemeta::core::HTTP_STATUS_PROCESSING
inlineconstexpr
Initial value:
{
.code = 102, .phrase = "Processing", .wire = "102 Processing"}

RFC 2518 §10.1 (WebDAV).

◆ HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED

HTTPStatus sourcemeta::core::HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED
inlineconstexpr
Initial value:
{
.code = 407,
.phrase = "Proxy Authentication Required",
.wire = "407 Proxy Authentication Required"}

RFC 9110 §15.5.8 (Client Error).

◆ HTTP_STATUS_RANGE_NOT_SATISFIABLE

HTTPStatus sourcemeta::core::HTTP_STATUS_RANGE_NOT_SATISFIABLE
inlineconstexpr
Initial value:
{
.code = 416,
.phrase = "Range Not Satisfiable",
.wire = "416 Range Not Satisfiable"}

RFC 9110 §15.5.17 (Client Error).

◆ HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE

HTTPStatus sourcemeta::core::HTTP_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE
inlineconstexpr
Initial value:
{
.code = 431,
.phrase = "Request Header Fields Too Large",
.wire = "431 Request Header Fields Too Large"}

RFC 6585 §5.

◆ HTTP_STATUS_REQUEST_TIMEOUT

HTTPStatus sourcemeta::core::HTTP_STATUS_REQUEST_TIMEOUT
inlineconstexpr
Initial value:
{
.code = 408, .phrase = "Request Timeout", .wire = "408 Request Timeout"}

RFC 9110 §15.5.9 (Client Error).

◆ HTTP_STATUS_RESET_CONTENT

HTTPStatus sourcemeta::core::HTTP_STATUS_RESET_CONTENT
inlineconstexpr
Initial value:
{
.code = 205, .phrase = "Reset Content", .wire = "205 Reset Content"}

RFC 9110 §15.3.6 (Successful).

◆ HTTP_STATUS_SEE_OTHER

HTTPStatus sourcemeta::core::HTTP_STATUS_SEE_OTHER
inlineconstexpr
Initial value:
{
.code = 303, .phrase = "See Other", .wire = "303 See Other"}

RFC 9110 §15.4.4 (Redirection).

◆ HTTP_STATUS_SERVICE_UNAVAILABLE

HTTPStatus sourcemeta::core::HTTP_STATUS_SERVICE_UNAVAILABLE
inlineconstexpr
Initial value:
{
.code = 503,
.phrase = "Service Unavailable",
.wire = "503 Service Unavailable"}

RFC 9110 §15.6.4 (Server Error).

◆ HTTP_STATUS_SWITCHING_PROTOCOLS

HTTPStatus sourcemeta::core::HTTP_STATUS_SWITCHING_PROTOCOLS
inlineconstexpr
Initial value:
{
.code = 101,
.phrase = "Switching Protocols",
.wire = "101 Switching Protocols"}

RFC 9110 §15.2.2 (Informational).

◆ HTTP_STATUS_TEMPORARY_REDIRECT

HTTPStatus sourcemeta::core::HTTP_STATUS_TEMPORARY_REDIRECT
inlineconstexpr
Initial value:
{
.code = 307,
.phrase = "Temporary Redirect",
.wire = "307 Temporary Redirect"}

RFC 9110 §15.4.8 (Redirection).

◆ HTTP_STATUS_TOO_EARLY

HTTPStatus sourcemeta::core::HTTP_STATUS_TOO_EARLY
inlineconstexpr
Initial value:
{
.code = 425, .phrase = "Too Early", .wire = "425 Too Early"}

RFC 8470 §5.2.

◆ HTTP_STATUS_TOO_MANY_REQUESTS

HTTPStatus sourcemeta::core::HTTP_STATUS_TOO_MANY_REQUESTS
inlineconstexpr
Initial value:
{
.code = 429,
.phrase = "Too Many Requests",
.wire = "429 Too Many Requests"}

RFC 6585 §4.

◆ HTTP_STATUS_UNAUTHORIZED

HTTPStatus sourcemeta::core::HTTP_STATUS_UNAUTHORIZED
inlineconstexpr
Initial value:
{
.code = 401, .phrase = "Unauthorized", .wire = "401 Unauthorized"}

RFC 9110 §15.5.2 (Client Error).

◆ HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS

HTTPStatus sourcemeta::core::HTTP_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS
inlineconstexpr
Initial value:
{
.code = 451,
.phrase = "Unavailable For Legal Reasons",
.wire = "451 Unavailable For Legal Reasons"}

RFC 7725 §3.

◆ HTTP_STATUS_UNPROCESSABLE_CONTENT

HTTPStatus sourcemeta::core::HTTP_STATUS_UNPROCESSABLE_CONTENT
inlineconstexpr
Initial value:
{
.code = 422,
.phrase = "Unprocessable Content",
.wire = "422 Unprocessable Content"}

RFC 9110 §15.5.21 (Client Error).

◆ HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE

HTTPStatus sourcemeta::core::HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE
inlineconstexpr
Initial value:
{
.code = 415,
.phrase = "Unsupported Media Type",
.wire = "415 Unsupported Media Type"}

RFC 9110 §15.5.16 (Client Error).

◆ HTTP_STATUS_UPGRADE_REQUIRED

HTTPStatus sourcemeta::core::HTTP_STATUS_UPGRADE_REQUIRED
inlineconstexpr
Initial value:
{
.code = 426, .phrase = "Upgrade Required", .wire = "426 Upgrade Required"}

RFC 9110 §15.5.22 (Client Error).

◆ HTTP_STATUS_URI_TOO_LONG

HTTPStatus sourcemeta::core::HTTP_STATUS_URI_TOO_LONG
inlineconstexpr
Initial value:
{
.code = 414, .phrase = "URI Too Long", .wire = "414 URI Too Long"}

RFC 9110 §15.5.15 (Client Error).

◆ HTTP_STATUS_USE_PROXY

HTTPStatus sourcemeta::core::HTTP_STATUS_USE_PROXY
inlineconstexpr
Initial value:
{
.code = 305, .phrase = "Use Proxy", .wire = "305 Use Proxy"}

RFC 9110 §15.4.6 (Redirection).

◆ HTTP_STATUS_VARIANT_ALSO_NEGOTIATES

HTTPStatus sourcemeta::core::HTTP_STATUS_VARIANT_ALSO_NEGOTIATES
inlineconstexpr
Initial value:
{
.code = 506,
.phrase = "Variant Also Negotiates",
.wire = "506 Variant Also Negotiates"}

RFC 2295 §8.1 (Transparent Content Negotiation).