Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::net::http::Header Class Reference

HTTP Header Key-Value Collection. More...

#include <Header.h>

Inheritance diagram for sese::net::http::Header:
sese::net::http::RequestHeader sese::net::http::ResponseHeader sese::net::http::Request sese::net::http::Response

Public Types

using Ptr = std::unique_ptr<Header>
 
using KeyValueType = std::pair<std::string, std::string>
 

Public Member Functions

 Header ()=default
 
 Header (const std::initializer_list< KeyValueType > &initializer_list) noexcept
 
virtual ~Header ()=default
 
void set (const std::string &key, const std::string &value) noexcept
 
const std::string & get (const std::string &key, const std::string &default_value) noexcept
 
std::map< std::string, std::string >::iterator begin () noexcept
 
std::map< std::string, std::string >::iterator end () noexcept
 
auto find (const std::string &key) noexcept
 
void clear ()
 
bool empty () const
 
size_t size () const
 
bool exist (const std::string &key)
 
const std::string & get (const std::string &key)
 
const CookieMap::PtrgetCookies () const
 
void setCookies (const CookieMap::Ptr &cookies)
 
Cookie::Ptr getCookie (const std::string &name) const
 
void setCookie (const Cookie::Ptr &cookie)
 

Protected Attributes

StrCaseMap< std::string > headers
 
CookieMap::Ptr cookies = nullptr
 

Detailed Description

HTTP Header Key-Value Collection.

Member Typedef Documentation

◆ KeyValueType

using sese::net::http::Header::KeyValueType = std::pair<std::string, std::string>

◆ Ptr

using sese::net::http::Header::Ptr = std::unique_ptr<Header>

Constructor & Destructor Documentation

◆ Header() [1/2]

sese::net::http::Header::Header ( )
explicitdefault

◆ Header() [2/2]

Header::Header ( const std::initializer_list< KeyValueType > & initializer_list)
noexcept

◆ ~Header()

virtual sese::net::http::Header::~Header ( )
virtualdefault

Member Function Documentation

◆ begin()

std::map< std::string, std::string >::iterator sese::net::http::Header::begin ( )
inlinenoexcept

References headers.

◆ clear()

void sese::net::http::Header::clear ( )
inline

References headers.

◆ empty()

bool sese::net::http::Header::empty ( ) const
inlinenodiscard

References headers.

◆ end()

std::map< std::string, std::string >::iterator sese::net::http::Header::end ( )
inlinenoexcept

References headers.

◆ exist()

bool sese::net::http::Header::exist ( const std::string & key)
inline

Determine if a field exists

Parameters
keyHeader field name
Returns
Result

References headers.

Referenced by sese::net::http::HttpConverter::convertFromHttp2().

◆ find()

auto sese::net::http::Header::find ( const std::string & key)
inlinenoexcept

References headers.

◆ get() [1/2]

const std::string & sese::net::http::Header::get ( const std::string & key)
inline

Call this when certain the field exists

See also
sese::net::http::Header::exist
Parameters
keyHeader field name
Returns
Value

References headers.

◆ get() [2/2]

const std::string & Header::get ( const std::string & key,
const std::string & default_value )
noexcept

◆ getCookie()

Cookie::Ptr Header::getCookie ( const std::string & name) const
nodiscard

Get a Cookie by name

Parameters
nameCookie name
Return values
nullptrif the Cookie does not exist

References cookies, and sese::net::http::CookieMap::find().

◆ getCookies()

const CookieMap::Ptr & Header::getCookies ( ) const
nodiscard

Get the current Cookie map

Return values
nullptrif the current map is empty

References cookies.

Referenced by sese::internal::net::http::HttpClientImpl::request().

◆ set()

void Header::set ( const std::string & key,
const std::string & value )
noexcept

◆ setCookie()

void Header::setCookie ( const Cookie::Ptr & cookie)

Add a Cookie

Parameters
cookieCookie to add

References sese::net::http::CookieMap::add(), and cookies.

◆ setCookies()

void Header::setCookies ( const CookieMap::Ptr & cookies)

Set the current Cookie map

Parameters
cookiesMap to set

References cookies.

Referenced by sese::internal::net::http::HttpClientImpl::HttpClientImpl().

◆ size()

size_t sese::net::http::Header::size ( ) const
inlinenodiscard

References headers.

Member Data Documentation

◆ cookies

CookieMap::Ptr sese::net::http::Header::cookies = nullptr
protected

◆ headers

StrCaseMap<std::string> sese::net::http::Header::headers
protected

Referenced by begin(), clear(), empty(), end(), exist(), find(), get(), and size().


The documentation for this class was generated from the following files: