Skip to content
Welcome to the new CppUtils documentation!

Namespace: CppUtils::Network::Http

enum class Method {
Unknown,
Get,
Post,
Put,
Delete,
Head,
Options,
Patch
};
enum class Status {
Continue = 100,
SwitchingProtocols = 101,
Processing = 102,
EarlyHints = 103,
Ok = 200,
Created = 201,
Accepted = 202,
NonAuthoritativeInformation = 203,
NoContent = 204,
ResetContent = 205,
PartialContent = 206,
MultiStatus = 207,
AlreadyReported = 208,
ImUsed = 226,
MultipleChoices = 300,
MovedPermanently = 301,
Found = 302,
SeeOther = 303,
NotModified = 304,
UseProxy = 305,
TemporaryRedirect = 307,
PermanentRedirect = 308,
BadRequest = 400,
Unauthorized = 401,
PaymentRequired = 402,
Forbidden = 403,
NotFound = 404,
MethodNotAllowed = 405,
NotAcceptable = 406,
ProxyAuthenticationRequired = 407,
RequestTimeout = 408,
Conflict = 409,
Gone = 410,
LengthRequired = 411,
PreconditionFailed = 412,
PayloadTooLarge = 413,
UriTooLong = 414,
UnsupportedMediaType = 415,
RangeNotSatisfiable = 416,
ExpectationFailed = 417,
ImATeapot = 418,
MisdirectedRequest = 421,
UnprocessableEntity = 422,
Locked = 423,
FailedDependency = 424,
TooEarly = 425,
UpgradeRequired = 426,
PreconditionRequired = 428,
TooManyRequests = 429,
RequestHeaderFieldsTooLarge = 431,
UnavailableForLegalReasons = 451,
InternalServerError = 500,
NotImplemented = 501,
BadGateway = 502,
ServiceUnavailable = 503,
GatewayTimeout = 504,
HttpVersionNotSupported = 505,
VariantAlsoNegotiates = 506,
InsufficientStorage = 507,
LoopDetected = 508,
NotExtended = 510,
NetworkAuthenticationRequired = 511
};
using CppUtils::Network::Http::MethodMapping = typedef Type::Mapping< Type::Pair<Method::Get, String::Hasher{"GET"}>, Type::Pair<Method::Post, String::Hasher{"POST"}>, Type::Pair<Method::Put, String::Hasher{"PUT"}>, Type::Pair<Method::Delete, String::Hasher{"DELETE"}>, Type::Pair<Method::Head, String::Hasher{"HEAD"}>, Type::Pair<Method::Options, String::Hasher{"OPTIONS"}>, Type::Pair<Method::Patch, String::Hasher{"PATCH"}>, Type::Pair<Method::Unknown, String::Hasher{"UNKNOWN"}> >;
using CppUtils::Network::Http::StatusMapping = typedef Type::Mapping< Type::Pair<Status::Continue, String::Hasher{"Continue"}>, Type::Pair<Status::SwitchingProtocols, String::Hasher{"Switching Protocols"}>, Type::Pair<Status::Processing, String::Hasher{"Processing"}>, Type::Pair<Status::EarlyHints, String::Hasher{"Early Hints"}>, Type::Pair<Status::Ok, String::Hasher{"OK"}>, Type::Pair<Status::Created, String::Hasher{"Created"}>, Type::Pair<Status::Accepted, String::Hasher{"Accepted"}>, Type::Pair<Status::NonAuthoritativeInformation, String::Hasher{"Non-Authoritative Information"}>, Type::Pair<Status::NoContent, String::Hasher{"No Content"}>, Type::Pair<Status::ResetContent, String::Hasher{"Reset Content"}>, Type::Pair<Status::PartialContent, String::Hasher{"Partial Content"}>, Type::Pair<Status::MultiStatus, String::Hasher{"Multi-Status"}>, Type::Pair<Status::AlreadyReported, String::Hasher{"Already Reported"}>, Type::Pair<Status::ImUsed, String::Hasher{"IM Used"}>, Type::Pair<Status::MultipleChoices, String::Hasher{"Multiple Choices"}>, Type::Pair<Status::MovedPermanently, String::Hasher{"Moved Permanently"}>, Type::Pair<Status::Found, String::Hasher{"Found"}>, Type::Pair<Status::SeeOther, String::Hasher{"See Other"}>, Type::Pair<Status::NotModified, String::Hasher{"Not Modified"}>, Type::Pair<Status::UseProxy, String::Hasher{"Use Proxy"}>, Type::Pair<Status::TemporaryRedirect, String::Hasher{"Temporary Redirect"}>, Type::Pair<Status::PermanentRedirect, String::Hasher{"Permanent Redirect"}>, Type::Pair<Status::BadRequest, String::Hasher{"Bad Request"}>, Type::Pair<Status::Unauthorized, String::Hasher{"Unauthorized"}>, Type::Pair<Status::PaymentRequired, String::Hasher{"Payment Required"}>, Type::Pair<Status::Forbidden, String::Hasher{"Forbidden"}>, Type::Pair<Status::NotFound, String::Hasher{"Not Found"}>, Type::Pair<Status::MethodNotAllowed, String::Hasher{"Method Not Allowed"}>, Type::Pair<Status::NotAcceptable, String::Hasher{"Not Acceptable"}>, Type::Pair<Status::ProxyAuthenticationRequired, String::Hasher{"Proxy Authentication Required"}>, Type::Pair<Status::RequestTimeout, String::Hasher{"Request Timeout"}>, Type::Pair<Status::Conflict, String::Hasher{"Conflict"}>, Type::Pair<Status::Gone, String::Hasher{"Gone"}>, Type::Pair<Status::LengthRequired, String::Hasher{"Length Required"}>, Type::Pair<Status::PreconditionFailed, String::Hasher{"Precondition Failed"}>, Type::Pair<Status::PayloadTooLarge, String::Hasher{"Payload Too Large"}>, Type::Pair<Status::UriTooLong, String::Hasher{"URI Too Long"}>, Type::Pair<Status::UnsupportedMediaType, String::Hasher{"Unsupported Media Type"}>, Type::Pair<Status::RangeNotSatisfiable, String::Hasher{"Range Not Satisfiable"}>, Type::Pair<Status::ExpectationFailed, String::Hasher{"Expectation Failed"}>, Type::Pair<Status::ImATeapot, String::Hasher{"I'm a teapot"}>, Type::Pair<Status::MisdirectedRequest, String::Hasher{"Misdirected Request"}>, Type::Pair<Status::UnprocessableEntity, String::Hasher{"Unprocessable Entity"}>, Type::Pair<Status::Locked, String::Hasher{"Locked"}>, Type::Pair<Status::FailedDependency, String::Hasher{"Failed Dependency"}>, Type::Pair<Status::TooEarly, String::Hasher{"Too Early"}>, Type::Pair<Status::UpgradeRequired, String::Hasher{"Upgrade Required"}>, Type::Pair<Status::PreconditionRequired, String::Hasher{"Precondition Required"}>, Type::Pair<Status::TooManyRequests, String::Hasher{"Too Many Requests"}>, Type::Pair<Status::RequestHeaderFieldsTooLarge, String::Hasher{"Request Header Fields Too Large"}>, Type::Pair<Status::UnavailableForLegalReasons, String::Hasher{"Unavailable For Legal Reasons"}>, Type::Pair<Status::InternalServerError, String::Hasher{"Internal Server Error"}>, Type::Pair<Status::NotImplemented, String::Hasher{"Not Implemented"}>, Type::Pair<Status::BadGateway, String::Hasher{"Bad Gateway"}>, Type::Pair<Status::ServiceUnavailable, String::Hasher{"Service Unavailable"}>, Type::Pair<Status::GatewayTimeout, String::Hasher{"Gateway Timeout"}>, Type::Pair<Status::HttpVersionNotSupported, String::Hasher{"HTTP Version Not Supported"}>, Type::Pair<Status::VariantAlsoNegotiates, String::Hasher{"Variant Also Negotiates"}>, Type::Pair<Status::InsufficientStorage, String::Hasher{"Insufficient Storage"}>, Type::Pair<Status::LoopDetected, String::Hasher{"Loop Detected"}>, Type::Pair<Status::NotExtended, String::Hasher{"Not Extended"}>, Type::Pair<Status::NetworkAuthenticationRequired, String::Hasher{"Network Authentication Required"}> >;
auto toString(Method method) -> std::string_view;

auto toMethod(std::string_view method) -> Method;

constexpr auto operator==(Status status, std::size_t value) noexcept -> bool;

auto toString(Status status) -> std::string_view;

auto findHeaderEnd(std::string_view buffer) -> std::size_t;

auto parseHeaderFields(auto linesRange) -> std::vector<Header>;

auto parseMessage(std::string_view serializedHeaders, auto&& firstLineParser);

auto getContentLength(const std::vector<Header> &headers) -> std::size_t;

template <class T>
auto readMessage(auto&& receiver, auto&& headerParser) -> std::expected<T, std::error_code>;