HTTP headers. More...
#include <headers.hpp>
Public Member Functions | |
std::optional< std::vector< std::string > > | get (const std::string &key) |
const std::optional< const std::vector< std::string > > | get (const std::string &key) const |
bool | has (const std::string &key) const |
bool | add (const std::string &name, const std::vector< std::string > &values) |
bool | add (const std::string &name, const std::string &value) |
void | put (const std::string &name, const std::vector< std::string > &values) |
void | put (const std::string &name, const std::string &value) |
std::optional< std::string > | format (const std::string &name) const |
HTTP headers.
This class add only formatting functions to map.
Conversions are done with:
get
will call find
after formattinghas
will call contains
after formattingput
and add
will call insert
after formattingMap methods will be masked to ensure headers formatting.
bool anch::rest::Headers::add | ( | const std::string & | name, |
const std::string & | value ) |
Insert header if not exists
name | the header name |
value | the header value |
true
when added, false
otherwise (when header already exists) bool anch::rest::Headers::add | ( | const std::string & | name, |
const std::vector< std::string > & | values ) |
Insert header if not exists
name | the header name |
values | the header values |
true
when added, false
otherwise (when header already exists) std::optional< std::string > anch::rest::Headers::format | ( | const std::string & | name | ) | const |
Format header
name | the header name |
std::optional< std::vector< std::string > > anch::rest::Headers::get | ( | const std::string & | key | ) |
Get header
key | the header name to find |
empty
if not found const std::optional< const std::vector< std::string > > anch::rest::Headers::get | ( | const std::string & | key | ) | const |
Get header
key | the header name to find |
empty
if not found bool anch::rest::Headers::has | ( | const std::string & | key | ) | const |
Check if header has been defined
key | the header name to find |
true
when header has been found, false
otherwise void anch::rest::Headers::put | ( | const std::string & | name, |
const std::string & | value ) |
Insert or replace header
name | the header name |
value | the header value |
void anch::rest::Headers::put | ( | const std::string & | name, |
const std::vector< std::string > & | values ) |
Insert or replace header
name | the header name |
values | the header values |