C++ Actor Framework 0.19
|
Encapsulates meta data for HTTP requests. More...
#include <request_header.hpp>
Public Member Functions | |
request_header ()=default | |
Default constructor. | |
request_header (request_header &&)=default | |
Move constructor. | |
request_header & | operator= (request_header &&)=default |
Move assignment operator. | |
request_header (const request_header &) | |
Copy constructor. | |
request_header & | operator= (const request_header &) |
Copy assignment operator. | |
void | assign (const request_header &) |
Assigns the content of another request_header. | |
http::method | method () const noexcept |
Returns the HTTP method of the request. | |
std::string_view | path () const noexcept |
Returns the path part of the request URI. | |
const uri::query_map & | query () const noexcept |
Returns the query part of the request URI as a map. | |
std::string_view | fragment () const noexcept |
Returns the fragment part of the request URI. | |
std::string_view | version () const noexcept |
Returns the HTTP version of the request. | |
size_t | num_fields () const noexcept |
Returns the number of fields in the request header. | |
std::pair< std::string_view, std::string_view > | field_at (size_t index) |
Returns the field at the specified index as a key-value pair. | |
bool | has_field (std::string_view key) const noexcept |
Checks if the request header has a field with the specified key. | |
std::string_view | field (std::string_view key) const noexcept |
Returns the value of the field with the specified key, or an empty view if the field is not found. | |
bool | field_equals (ignore_case_t, std::string_view key, std::string_view val) const noexcept |
Checks whether the field key exists and equals val when using case-insensitive compare. | |
bool | field_equals (std::string_view key, std::string_view val) const noexcept |
Checks whether the field key exists and equals val when using case-insensitive compare. | |
template<class T > | |
std::optional< T > | field_as (std::string_view key) const noexcept |
Returns the value of the field with the specified key as the requested type T, or std::nullopt if the field is not found or cannot be converted. | |
template<class F > | |
void | for_each_field (F &&f) const |
Executes the provided callable f for each field in the request header. | |
bool | valid () const noexcept |
Checks if the request header is valid (non-empty). | |
bool | chunked_transfer_encoding () const |
Checks whether the client has defined Transfer-Encoding as chunked . | |
std::optional< size_t > | content_length () const |
Convenience function for field_as<size_t>("Content-Length") . | |
std::pair< status, std::string_view > | parse (std::string_view raw) |
Parses a raw request header string and returns a pair containing the status and a description for the status. | |
Friends | |
class | http::server |
class | web_socket::server |
Encapsulates meta data for HTTP requests.
This class represents an HTTP request header, providing methods for accessing the HTTP method, path, query, fragment, version, and fields.
void caf::net::http::request_header::for_each_field | ( | F && | f | ) | const |
Executes the provided callable f
for each field in the request header.
f | A function object taking two std::string_view parameters: key and value. |
std::pair< status, std::string_view > caf::net::http::request_header::parse | ( | std::string_view | raw | ) |
Parses a raw request header string and returns a pair containing the status and a description for the status.
status::bad_request
on error with a human-readable description of the error, status::ok
otherwise.