RESTinio
Loading...
Searching...
No Matches
restinio::http_header_common_t Struct Reference

Req/Resp headers common data. More...

#include <http_headers.hpp>

Inheritance diagram for restinio::http_header_common_t:
restinio::http_header_fields_t restinio::http_request_header_t restinio::http_response_header_t

Public Member Functions

std::uint64_t content_length () const noexcept
 Length of body of an http-message.
void content_length (std::uint64_t l) noexcept
bool should_keep_alive () const noexcept
void should_keep_alive (bool keep_alive) noexcept
http_connection_header_t connection () const
 Get the value of 'connection' header field.
void connection (http_connection_header_t ch) noexcept
 Set the value of 'connection' header field.
std::uint16_t http_major () const noexcept
 Http version.
void http_major (std::uint16_t v) noexcept
std::uint16_t http_minor () const noexcept
void http_minor (std::uint16_t v) noexcept
Public Member Functions inherited from restinio::http_header_fields_t
 http_header_fields_t ()
 http_header_fields_t (const http_header_fields_t &)=default
 http_header_fields_t (http_header_fields_t &&)=default
virtual ~http_header_fields_t ()
http_header_fields_toperator= (const http_header_fields_t &)=default
http_header_fields_toperator= (http_header_fields_t &&)=default
void swap_fields (http_header_fields_t &http_header_fields)
bool has_field (string_view_t field_name) const noexcept
 Check field by name.
bool has_field (http_field_t field_id) const noexcept
 Check field by field-id.
void set_field (http_header_field_t http_header_field)
 Set header field via http_header_field_t.
void set_field (std::string field_name, std::string field_value)
 Set field with string pair.
void set_field (http_field_t field_id, std::string field_value)
 Set field with id-value pair.
void add_field (http_field_t field_id, std::string field_value)
 Add a field in the form of id-value pair.
void add_field (std::string field_name, std::string field_value)
 Add a field in the form of name-value pair.
void add_field (http_header_field_t http_header_field)
 Add a field in the form of http_header_field object.
void append_field (string_view_t field_name, string_view_t field_value)
 Append field with name.
void append_field (http_field_t field_id, string_view_t field_value)
 Append field with id.
const std::string & get_field (string_view_t field_name) const
 Get field by name.
nullable_pointer_t< const std::string > try_get_field (string_view_t field_name) const noexcept
 Try to get the value of a field by field name.
const std::string & get_field (http_field_t field_id) const
 Get field by id.
nullable_pointer_t< const std::string > try_get_field (http_field_t field_id) const noexcept
 Try to get the value of a field by field ID.
std::string get_field_or (string_view_t field_name, string_view_t default_value) const
 Get field value by field name or default value if the field not found.
std::string get_field_or (string_view_t field_name, std::string &&default_value) const
 Get field value by field name or default value if the field not found.
auto get_field_or (string_view_t field_name, const char *default_value) const
 Get field by name or default value if the field not found.
auto get_field_or (string_view_t field_name, const std::string &default_value) const
 Get field by name or default value if the field not found.
std::string get_field_or (http_field_t field_id, string_view_t default_value) const
 Get field by id or default value if the field not found.
auto get_field_or (http_field_t field_id, const char *default_value) const
 Get field by id or default value if the field not found.
auto get_field_or (http_field_t field_id, const std::string &default_value) const
 Get field by id or default value if the field not found.
std::string get_field_or (http_field_t field_id, std::string &&default_value) const
 Get field by id or default value if the field not found.
bool remove_field (string_view_t field_name) noexcept
 Remove field by name.
bool remove_field (http_field_t field_id) noexcept
 Remove field by id.
std::size_t remove_all_of (string_view_t field_name) noexcept
 Remove all occurences of a field with specified name.
std::size_t remove_all_of (http_field_t field_id) noexcept
 Remove all occurences of a field with specified id.
template<typename Lambda>
void for_each_field (Lambda &&lambda) const noexcept(noexcept(lambda(std::declval< const http_header_field_t & >())))
 Enumeration of fields.
template<typename Lambda>
void for_each_value_of (http_field_t field_id, Lambda &&lambda) const noexcept(noexcept(lambda(std::declval< const string_view_t & >())))
 Enumeration of each value of a field.
template<typename Lambda>
void for_each_value_of (string_view_t field_name, Lambda &&lambda) const noexcept(noexcept(lambda(std::declval< const string_view_t & >())))
 Enumeration of each value of a field.
const_iterator begin () const noexcept
const_iterator end () const noexcept
auto fields_count () const noexcept
string_view_t value_of (string_view_t name) const
 Get the value of a field or throw if the field not found.
string_view_t value_of (http_field_t field_id) const
 Get the value of a field or throw if the field not found.
std::optional< string_view_topt_value_of (string_view_t name) const noexcept
 Get optional value of a field.
std::optional< string_view_topt_value_of (http_field_t field_id) const noexcept
 Get optional value of a field.

Private Attributes

std::uint64_t m_content_length { 0 }
 Length of body of an http-message.
http_connection_header_t m_http_connection_header_field_value { http_connection_header_t::close }
std::uint16_t m_http_major {1}
 Http version.
std::uint16_t m_http_minor {1}

Additional Inherited Members

Public Types inherited from restinio::http_header_fields_t
enum class  handling_result_t { continue_enumeration , stop_enumeration }
 The result of handling yet another field value. More...
using fields_container_t = std::vector< http_header_field_t >
using const_iterator = fields_container_t::const_iterator
 Type of const_iterator for enumeration of fields.
Static Public Member Functions inherited from restinio::http_header_fields_t
static constexpr handling_result_t continue_enumeration () noexcept
static constexpr handling_result_t stop_enumeration () noexcept

Detailed Description

Req/Resp headers common data.

Definition at line 1580 of file http_headers.hpp.

Member Function Documentation

◆ connection() [1/2]

http_connection_header_t restinio::http_header_common_t::connection ( ) const
inline

Get the value of 'connection' header field.

Definition at line 1628 of file http_headers.hpp.

◆ connection() [2/2]

void restinio::http_header_common_t::connection ( http_connection_header_t ch)
inlinenoexcept

Set the value of 'connection' header field.

Definition at line 1635 of file http_headers.hpp.

◆ content_length() [1/2]

std::uint64_t restinio::http_header_common_t::content_length ( ) const
inlinenoexcept

Length of body of an http-message.

Definition at line 1605 of file http_headers.hpp.

◆ content_length() [2/2]

void restinio::http_header_common_t::content_length ( std::uint64_t l)
inlinenoexcept

Definition at line 1609 of file http_headers.hpp.

◆ http_major() [1/2]

std::uint16_t restinio::http_header_common_t::http_major ( ) const
inlinenoexcept

Http version.

Definition at line 1587 of file http_headers.hpp.

◆ http_major() [2/2]

void restinio::http_header_common_t::http_major ( std::uint16_t v)
inlinenoexcept

Definition at line 1591 of file http_headers.hpp.

◆ http_minor() [1/2]

std::uint16_t restinio::http_header_common_t::http_minor ( ) const
inlinenoexcept

Definition at line 1595 of file http_headers.hpp.

◆ http_minor() [2/2]

void restinio::http_header_common_t::http_minor ( std::uint16_t v)
inlinenoexcept

Definition at line 1599 of file http_headers.hpp.

◆ should_keep_alive() [1/2]

bool restinio::http_header_common_t::should_keep_alive ( ) const
inlinenoexcept

Definition at line 1613 of file http_headers.hpp.

◆ should_keep_alive() [2/2]

void restinio::http_header_common_t::should_keep_alive ( bool keep_alive)
inlinenoexcept

Definition at line 1619 of file http_headers.hpp.

Member Data Documentation

◆ m_content_length

std::uint64_t restinio::http_header_common_t::m_content_length { 0 }
private

Length of body of an http-message.

Definition at line 1648 of file http_headers.hpp.

◆ m_http_connection_header_field_value

http_connection_header_t restinio::http_header_common_t::m_http_connection_header_field_value { http_connection_header_t::close }
private

Definition at line 1650 of file http_headers.hpp.

◆ m_http_major

std::uint16_t restinio::http_header_common_t::m_http_major {1}
private

Http version.

Definition at line 1643 of file http_headers.hpp.

◆ m_http_minor

std::uint16_t restinio::http_header_common_t::m_http_minor {1}
private

Definition at line 1644 of file http_headers.hpp.


The documentation for this struct was generated from the following file: