1#ifndef SOURCEMETA_CORE_HTTP_H_
2#define SOURCEMETA_CORE_HTTP_H_
4#ifndef SOURCEMETA_CORE_HTTP_EXPORT
5#include <sourcemeta/core/http_export.h>
9#include <sourcemeta/core/http_aws_sigv4.h>
10#include <sourcemeta/core/http_error.h>
11#include <sourcemeta/core/http_message.h>
12#include <sourcemeta/core/http_method.h>
13#include <sourcemeta/core/http_problem.h>
14#include <sourcemeta/core/http_status.h>
15#include <sourcemeta/core/http_syntax.h>
16#include <sourcemeta/core/http_system.h>
22#include <initializer_list>
49namespace sourcemeta::core {
74SOURCEMETA_CORE_HTTP_EXPORT
76 std::initializer_list<std::string_view> candidates)
93SOURCEMETA_CORE_HTTP_EXPORT
95 const std::string_view accept_header,
96 std::initializer_list<std::string_view> media_types)
noexcept -> bool;
111SOURCEMETA_CORE_HTTP_EXPORT
113 const std::string_view media_type)
noexcept
150SOURCEMETA_CORE_HTTP_EXPORT
152 -> std::optional<HTTPMediaType>;
175SOURCEMETA_CORE_HTTP_EXPORT
177 std::span<const std::string_view> ranges)
noexcept
196SOURCEMETA_CORE_HTTP_EXPORT
198 const std::string_view accept_language_header,
199 std::initializer_list<std::string_view> candidates) -> std::string_view;
214SOURCEMETA_CORE_HTTP_EXPORT
216 const std::string_view accept_encoding_header,
218 -> std::optional<HTTPContentEncoding>;
234SOURCEMETA_CORE_HTTP_EXPORT
236 -> std::optional<std::chrono::system_clock::time_point>;
254SOURCEMETA_CORE_HTTP_EXPORT
256 -> std::optional<std::chrono::seconds>;
268 std::span<const std::pair<std::string_view, std::string_view>>
parameters{};
284SOURCEMETA_CORE_HTTP_EXPORT
299SOURCEMETA_CORE_HTTP_EXPORT
319SOURCEMETA_CORE_HTTP_EXPORT
337SOURCEMETA_CORE_HTTP_EXPORT
365 std::optional<std::chrono::seconds>
max_age{};
401SOURCEMETA_CORE_HTTP_EXPORT
427SOURCEMETA_CORE_HTTP_EXPORT
429 std::string &out) -> bool;
443SOURCEMETA_CORE_HTTP_EXPORT
445 -> std::optional<std::string>;
460 std::span<const std::pair<std::string_view, std::string_view>>
parameters{};
487SOURCEMETA_CORE_HTTP_EXPORT
516SOURCEMETA_CORE_HTTP_EXPORT
523SOURCEMETA_CORE_HTTP_EXPORT
525 -> std::optional<std::string>;
532SOURCEMETA_CORE_HTTP_EXPORT
534 std::string &out) -> bool;
555SOURCEMETA_CORE_HTTP_EXPORT
557 -> std::optional<std::string>;
602SOURCEMETA_CORE_HTTP_EXPORT
604 std::vector<HTTPParsedChallenge> &challenges)
630 std::optional<std::string_view>
path{};
632 std::optional<std::string_view>
domain{};
634 std::optional<std::chrono::seconds>
max_age{};
676SOURCEMETA_CORE_HTTP_EXPORT
695SOURCEMETA_CORE_HTTP_EXPORT
710SOURCEMETA_CORE_HTTP_EXPORT
712 -> std::optional<std::string>;
730SOURCEMETA_CORE_HTTP_EXPORT
746SOURCEMETA_CORE_HTTP_EXPORT
748 const std::string_view header_value,
749 std::initializer_list<std::string_view> tokens)
noexcept -> bool;
775SOURCEMETA_CORE_HTTP_EXPORT
777 std::string &out) -> bool;
796SOURCEMETA_CORE_HTTP_EXPORT
798 -> std::optional<std::string>;
814SOURCEMETA_CORE_HTTP_EXPORT
std::string_view rel
The link relation type.
Definition http.h:266
std::vector< std::pair< std::string, std::string > > parameters
The authentication parameters, in the order they appeared.
Definition http.h:570
std::optional< std::string_view > token68
The credential the challenge carries in place of parameters.
Definition http.h:458
bool no_store
Whether no cache may store any part of the exchange (RFC 9111 §5.2.2.5).
Definition http.h:370
std::span< const std::string_view > private_fields
Definition http.h:388
bool proxy_revalidate
The same for a shared cache alone (RFC 9111 §5.2.2.8).
Definition http.h:378
bool secure
Whether the cookie is only sent over secure channels.
Definition http.h:638
std::optional< std::chrono::seconds > max_age
The cookie lifetime.
Definition http.h:634
std::span< const std::string_view > no_cache_fields
Definition http.h:391
std::string_view parameters
The parameters that follow the type, starting at the first ;.
Definition http.h:129
bool http_only
Whether the cookie is withheld from scripts.
Definition http.h:636
std::optional< std::string > token68
The credential the challenge carried in place of parameters.
Definition http.h:568
std::optional< std::string_view > domain
The host the cookie is scoped to.
Definition http.h:632
bool no_cache
Definition http.h:373
std::string scheme
The authentication scheme, as spelled in the field.
Definition http.h:566
std::optional< std::chrono::seconds > max_age
How long the response stays fresh (RFC 9111 §5.2.2.1).
Definition http.h:365
std::string_view name
The cookie name.
Definition http.h:626
bool must_revalidate
Definition http.h:376
std::span< const std::pair< std::string_view, std::string_view > > parameters
The authentication parameters.
Definition http.h:460
bool immutable
Whether the response will not be updated while fresh (RFC 8246).
Definition http.h:385
std::span< const std::pair< std::string_view, std::string_view > > parameters
The additional target attributes of the link.
Definition http.h:268
std::optional< HTTPCacheVisibility > visibility
Which caches may store the response.
Definition http.h:363
std::optional< HTTPCookieSameSite > same_site
The cross-site request policy for the cookie.
Definition http.h:640
std::string_view subtype
The subtype, such as geo+json.
Definition http.h:123
std::optional< std::chrono::seconds > shared_max_age
Definition http.h:368
bool must_understand
Definition http.h:381
std::optional< std::string_view > path
The path the cookie is scoped to.
Definition http.h:630
std::string_view target
The link target reference.
Definition http.h:264
std::string_view type
The type, such as application.
Definition http.h:121
std::string_view value
The cookie value.
Definition http.h:628
bool no_transform
Whether the payload must not be transformed (RFC 9111 §5.2.2.6).
Definition http.h:383
std::string_view suffix
Definition http.h:127
std::string_view scheme
The authentication scheme.
Definition http.h:456
HTTPCacheVisibility
Definition http.h:344
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
SOURCEMETA_CORE_HTTP_EXPORT auto http_from_date(const std::string_view value) noexcept -> std::optional< std::chrono::system_clock::time_point >
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
HTTPCookieSameSite
Definition http.h:609
SOURCEMETA_CORE_HTTP_EXPORT auto http_cache_control_valid(const HTTPCacheControl &directives) -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto http_parse_media_type(const std::string_view media_type) -> std::optional< HTTPMediaType >
SOURCEMETA_CORE_HTTP_EXPORT auto http_parse_bearer(const std::string_view authorization) noexcept -> std::string_view
SOURCEMETA_CORE_HTTP_EXPORT auto http_serialize_challenge(const HTTPChallenge &challenge, std::string &out) -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto http_match_accept(const std::string_view accept_header, std::initializer_list< std::string_view > candidates) -> std::string_view
SOURCEMETA_CORE_HTTP_EXPORT auto http_serialize_cookie(const HTTPCookie &cookie, std::string &out) -> bool
constexpr std::size_t HTTP_COOKIE_MAXIMUM_ATTRIBUTE_VALUE_LENGTH
Definition http.h:655
constexpr std::size_t HTTP_COOKIE_MAXIMUM_NAME_VALUE_LENGTH
Definition http.h:649
SOURCEMETA_CORE_HTTP_EXPORT auto http_content_type_matches(const std::string_view content_type_header, const std::string_view media_type) noexcept -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto http_match_media_range(const std::string_view media_type, std::span< const std::string_view > ranges) noexcept -> std::string_view
SOURCEMETA_CORE_HTTP_EXPORT auto http_format_links(std::span< const HTTPLink > links, std::string &out) -> void
SOURCEMETA_CORE_HTTP_EXPORT auto http_challenge_valid(const HTTPChallenge &challenge) -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto http_expire_cookie(const HTTPCookie &cookie) -> HTTPCookie
SOURCEMETA_CORE_HTTP_EXPORT auto http_negotiate_encoding(const std::string_view accept_encoding_header, const HTTPContentEncoding server_preference) noexcept -> std::optional< HTTPContentEncoding >
SOURCEMETA_CORE_HTTP_EXPORT auto http_serialize_challenges(std::span< const HTTPChallenge > challenges, std::string &out) -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto http_format_vary(std::span< const std::string_view > field_names, std::string &out) -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto http_format_link(const HTTPLink &link, std::string &out) -> void
SOURCEMETA_CORE_HTTP_EXPORT auto http_parse_challenges(const std::string_view input, std::vector< HTTPParsedChallenge > &challenges) -> bool
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
SOURCEMETA_CORE_HTTP_EXPORT auto http_cookie_valid(const HTTPCookie &cookie) -> bool
HTTPContentEncoding
Definition http.h:53
SOURCEMETA_CORE_HTTP_EXPORT auto http_serialize_cache_control(const HTTPCacheControl &directives, std::string &out) -> bool
SOURCEMETA_CORE_HTTP_EXPORT auto http_cache_control_max_age(const std::string_view cache_control) noexcept -> std::optional< std::chrono::seconds >
@ Public
Definition http.h:348
@ Private
Definition http.h:351
@ Strict
The cookie is withheld from every cross-site request.
Definition http.h:611
@ None
The cookie is sent on every cross-site request.
Definition http.h:615
@ Lax
The cookie is sent on top-level cross-site navigations only.
Definition http.h:613
@ Identity
The identity coding that applies no transformation.
Definition http.h:55
@ GZIP
The gzip coding per RFC 9110 §8.4.1.3.
Definition http.h:57