HTTP helpers.
Namespaces | |
namespace | headers |
Common HTTP headers. | |
Classes | |
class | ContentType |
Content-Type representation. More... | |
class | ContentTypeHash |
struct | DecomposedUrlView |
class | MalformedContentType |
Content-Type parsing error. More... | |
Typedefs | |
using | Args = std::unordered_map< std::string, std::string, utils::StrCaseHash > |
using | MultiArgs = std::multimap< std::string, std::string > |
using | PathArgs = std::unordered_map< std::string, std::string > |
Enumerations | |
enum class | HttpVersion { kDefault , k10 , k11 , k2 , k2Tls , k2PriorKnowledge } |
HTTP version to use. More... | |
enum | StatusCode : uint16_t { kInvalid = 0 , kContinue = 100 , kSwitchingProtocols = 101 , kProcessing = 102 , kEarlyHints = 103 , kOk = 200 , kCreated = 201 , kAccepted = 202 , kNonAuthoritativeInformation = 203 , kNoContent = 204 , kResetContent = 205 , kPartialContent = 206 , kMultiStatus = 207 , kAlreadyReported = 208 , kThisIsFine = 218 , kImUsed = 226 , kMultipleChoices = 300 , kMovedPermanently = 301 , kFound = 302 , kSeeOther = 303 , kNotModified = 304 , kUseProxy = 305 , kSwitchProxy = 306 , kTemporaryRedirect = 307 , kPermanentRedirect = 308 , kBadRequest = 400 , kUnauthorized = 401 , kPaymentRequired = 402 , kForbidden = 403 , kNotFound = 404 , kMethodNotAllowed = 405 , kNotAcceptable = 406 , kProxyAuthenticationRequired = 407 , kRequestTimeout = 408 , kConflict = 409 , kGone = 410 , kLengthRequired = 411 , kPreconditionFailed = 412 , kPayloadTooLarge = 413 , kUriTooLong = 414 , kUnsupportedMediaType = 415 , kRangeNotSatisfiable = 416 , kExpectationFailed = 417 , kImATeapot = 418 , kPageExpired = 419 , kMethodFailure = 420 , kMisdirectedRequest = 421 , kUnprocessableEntity = 422 , kLocked = 423 , kFailedDependency = 424 , kTooEarly = 425 , kUpgradeRequired = 426 , kPreconditionRequired = 428 , kTooManyRequests = 429 , kRequestHeaderFieldsTooLarge = 431 , kNginxNoResponse = 444 , kUnavailableForLegalReasons = 451 , kNginxRequestHeaderTooLarge = 494 , kNginxSSLCertificateError = 495 , kNginxSSLCertificateRequired = 496 , kNginxHTTPRequestSenttoHTTPSPort = 497 , kDeadlineExpired = 498 , kNginxClientClosedRequest = 499 , kInternalServerError = 500 , kNotImplemented = 501 , kBadGateway = 502 , kServiceUnavailable = 503 , kGatewayTimeout = 504 , kHttpVersionNotSupported = 505 , kVariantAlsoNegotiates = 506 , kInsufficientStorage = 507 , kLoopDetected = 508 , kBandwidthLimitExceeded = 509 , kNotExtended = 510 , kNetworkAuthenticationRequired = 511 , kWebServerIsDown = 520 , kConnectionTimedOut = 522 , kOriginIsUnreachable = 523 , kTimeoutOccurred = 524 , kSslHandshakeFailed = 525 , kInvalidSslCertificate = 526 , Invalid = kInvalid , OK = kOk , Created = kCreated , NoContent = kNoContent , BadRequest = kBadRequest , NotFound = kNotFound , Conflict = kConflict , TooManyRequests = kTooManyRequests , InternalServerError = kInternalServerError , kClientClosedRequest = kNginxClientClosedRequest } |
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes More... | |
Functions | |
bool | operator== (const ContentType &, const ContentType &) |
bool | operator!= (const ContentType &, const ContentType &) |
bool | operator< (const ContentType &, const ContentType &) |
std::string_view | ToString (HttpVersion version) |
HttpVersion | HttpVersionFromString (std::string_view version) |
HttpVersion | Parse (const yaml_config::YamlConfig &value, formats::parse::To< HttpVersion >) |
std::string_view | StatusCodeString (StatusCode status) |
std::string | ToString (StatusCode status) |
std::ostream & | operator<< (std::ostream &os, StatusCode s) |
std::string | UrlDecode (std::string_view range) |
Decode URL. | |
std::string | UrlEncode (std::string_view input_string) |
Encode as URL. | |
std::string | MakeQuery (const Args &query_args) |
Make an URL query. | |
std::string | MakeQuery (const MultiArgs &query_args) |
Make an URL query. | |
std::string | MakeQuery (const std::unordered_map< std::string, std::string > &query_args) |
Make an URL query. | |
std::string | MakeQuery (std::initializer_list< std::pair< std::string_view, std::string_view > > query_args) |
Make an URL query. | |
std::string | MakeUrl (std::string_view path, const Args &query_args) |
Make an URL with query arguments. | |
std::string | MakeUrl (std::string_view path, const std::unordered_map< std::string, std::string > &query_args) |
Make an URL with query arguments. | |
std::string | MakeUrl (std::string_view path, const Args &query_args, MultiArgs query_multiargs) |
Make an URL with query arguments. | |
std::string | MakeUrl (std::string_view path, std::initializer_list< std::pair< std::string_view, std::string_view > > query_args) |
Make an URL with query arguments. | |
std::optional< std::string > | MakeUrlWithPathArgs (std::string_view path, const PathArgs &path_args) |
Make a path from a template and arguments. | |
std::optional< std::string > | MakeUrlWithPathArgs (std::string_view path, const PathArgs &path_args, const Args &query_args) |
Make an URL with path parameters and query arguments. | |
std::optional< std::string > | MakeUrlWithPathArgs (std::string_view path, const PathArgs &path_args, const std::unordered_map< std::string, std::string > &query_args) |
Make an URL with path parameters and query arguments. | |
std::optional< std::string > | MakeUrlWithPathArgs (std::string_view path, const PathArgs &path_args, const Args &query_args, MultiArgs query_multiargs) |
Make an URL with path parameters and query arguments, supporting multiple values for the same key. | |
std::optional< std::string > | MakeUrlWithPathArgs (std::string_view path, const PathArgs &path_args, std::initializer_list< std::pair< std::string_view, std::string_view > > query_args) |
Make an URL with path parameters and query arguments. | |
std::string | ExtractMetaTypeFromUrl (std::string_view url) |
Returns URL part before the first '?' character. | |
std::string_view | ExtractMetaTypeFromUrlView (std::string_view url) |
std::string | ExtractPath (std::string_view url) |
Returns HTTP path part of a URL. | |
std::string_view | ExtractPathView (std::string_view url) |
std::string | ExtractPathOnly (std::string_view url) |
Returns HTTP path part of a URL. | |
std::string | ExtractHostname (std::string_view url) |
Returns hostname part of a URL. | |
std::string_view | ExtractHostnameView (std::string_view url) |
std::string | ExtractScheme (std::string_view url) |
Returns scheme part of a URL. | |
std::string_view | ExtractSchemeView (std::string_view url) |
std::string | ExtractQuery (std::string_view url) |
Returns query part of a URL. | |
std::string_view | ExtractQueryView (std::string_view url) |
std::string | ExtractFragment (std::string_view url) |
Returns fragment part of a URL. | |
std::string_view | ExtractFragmentView (std::string_view url) |
DecomposedUrlView | DecomposeUrlIntoViews (std::string_view url) |
Returns decomposed URL as a struct, broken into main parts: scheme, host, path, query, and fragment. | |
template<typename Value , typename = std::enable_if_t<formats::common::kIsFormatValue<Value>>> | |
StatusCode | Parse (const Value &value, formats::parse::To< StatusCode >) |
using http::Args = typedef std::unordered_map<std::string, std::string, utils::StrCaseHash> |
using http::MultiArgs = typedef std::multimap<std::string, std::string> |
using http::PathArgs = typedef std::unordered_map<std::string, std::string> |
|
strong |
HTTP version to use.
Definition at line 15 of file http_version.hpp.
enum http::StatusCode : uint16_t |
https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
Definition at line 16 of file status_code.hpp.
std::string http::ExtractFragment | ( | std::string_view | url | ) |
Returns fragment part of a URL.
url | Full URL to extract from |
std::string http::ExtractHostname | ( | std::string_view | url | ) |
Returns hostname part of a URL.
url | Full URL to extract from |
std::string http::ExtractMetaTypeFromUrl | ( | std::string_view | url | ) |
Returns URL part before the first '?' character.
url | Full URL to extract from |
std::string http::ExtractPath | ( | std::string_view | url | ) |
Returns HTTP path part of a URL.
url | Full URL to extract from |
std::string http::ExtractPathOnly | ( | std::string_view | url | ) |
Returns HTTP path part of a URL.
url | Full URL to extract from |
std::string http::ExtractQuery | ( | std::string_view | url | ) |
Returns query part of a URL.
url | Full URL to extract from |
std::string http::ExtractScheme | ( | std::string_view | url | ) |
Returns scheme part of a URL.
url | Full URL to extract from |
std::string http::MakeQuery | ( | const Args & | query_args | ) |
Make an URL query.
query_args | Map of query parameters |
std::string http::MakeQuery | ( | const MultiArgs & | query_args | ) |
Make an URL query.
query_args | Multimap of query parameters |
std::string http::MakeQuery | ( | const std::unordered_map< std::string, std::string > & | query_args | ) |
Make an URL query.
query_args | Map of query parameters |
std::string http::MakeQuery | ( | std::initializer_list< std::pair< std::string_view, std::string_view > > | query_args | ) |
Make an URL query.
query_args | Initializer list of query parameters as key-value pairs |
std::string http::MakeUrl | ( | std::string_view | path, |
const Args & | query_args | ||
) |
Make an URL with query arguments.
path | Base URL path |
query_args | Map of query parameters |
std::string http::MakeUrl | ( | std::string_view | path, |
const Args & | query_args, | ||
MultiArgs | query_multiargs | ||
) |
Make an URL with query arguments.
path | Base URL path |
query_args | Map of query parameters |
query_multiargs | Multimap for query parameters that can have multiple values |
std::string http::MakeUrl | ( | std::string_view | path, |
const std::unordered_map< std::string, std::string > & | query_args | ||
) |
Make an URL with query arguments.
path | Base URL path |
query_args | Map of query parameters |
std::string http::MakeUrl | ( | std::string_view | path, |
std::initializer_list< std::pair< std::string_view, std::string_view > > | query_args | ||
) |
Make an URL with query arguments.
path | Base URL path |
query_args | Initializer list of query parameters as key-value pairs |
std::optional< std::string > http::MakeUrlWithPathArgs | ( | std::string_view | path, |
const PathArgs & | path_args | ||
) |
Make a path from a template and arguments.
path | Template string with placeholders in format {name} |
path_args | Map of placeholder names to their values |
std::optional< std::string > http::MakeUrlWithPathArgs | ( | std::string_view | path, |
const PathArgs & | path_args, | ||
const Args & | query_args | ||
) |
Make an URL with path parameters and query arguments.
path | Template string with placeholders in format {name} |
path_args | Map of placeholder names to their values |
query_args | Map of query parameters |
std::optional< std::string > http::MakeUrlWithPathArgs | ( | std::string_view | path, |
const PathArgs & | path_args, | ||
const Args & | query_args, | ||
MultiArgs | query_multiargs | ||
) |
Make an URL with path parameters and query arguments, supporting multiple values for the same key.
path | Template string with placeholders in format {name} |
path_args | Map of placeholder names to their values |
query_args | Map of query parameters |
query_multiargs | Multimap for query parameters that can have multiple values |
std::optional< std::string > http::MakeUrlWithPathArgs | ( | std::string_view | path, |
const PathArgs & | path_args, | ||
const std::unordered_map< std::string, std::string > & | query_args | ||
) |
Make an URL with path parameters and query arguments.
path | Template string with placeholders in format {name} |
path_args | Map of placeholder names to their values |
query_args | Map of query parameters |
std::optional< std::string > http::MakeUrlWithPathArgs | ( | std::string_view | path, |
const PathArgs & | path_args, | ||
std::initializer_list< std::pair< std::string_view, std::string_view > > | query_args | ||
) |
Make an URL with path parameters and query arguments.
path | Template string with placeholders in format {name} |
path_args | Map of placeholder names to their values |
query_args | Initializer list of query parameters as key-value pairs |
bool http::operator< | ( | const ContentType & | , |
const ContentType & | |||
) |
Weak ordering for Accept media-ranges checking. Positions less specific types before more specific, so that the most specific type can be matched first.
StatusCode http::Parse | ( | const Value & | value, |
formats::parse::To< StatusCode > | |||
) |
Definition at line 16 of file parse_status_code.hpp.
std::string http::UrlEncode | ( | std::string_view | input_string | ) |
Encode as URL.
input_string | String to encode |