net-cpp ..
C++11 library for networking purposes
core::net::http::Header Class Reference

The Header class encapsulates the headers of an HTTP request/response. More...

#include <header.h>

+ Collaboration diagram for core::net::http::Header:

Public Member Functions

virtual ~Header ()=default
 
virtual bool has (const std::string &key, const std::string &value) const
 has checks if the header contains an entry for the given key with the given value. More...
 
virtual bool has (const std::string &key) const
 has checks if the header contains any entry for the given key. More...
 
virtual void add (const std::string &key, const std::string &value)
 add adds the given value for the given key to the header. More...
 
virtual void remove (const std::string &key)
 remove erases all values for the given key from the header. More...
 
virtual void remove (const std::string &key, const std::string &value)
 remove erases the given value for the given key from the header. More...
 
virtual void set (const std::string &key, const std::string &value)
 set assigns the given value to the entry with key 'key' and replaces any previous value. More...
 
virtual void enumerate (const std::function< void(const std::string &, const std::set< std::string > &)> &enumerator) const
 enumerate iterates over the known fields and invokes the given enumerator for each of them. More...
 

Static Public Member Functions

static std::string canonicalize_key (const std::string &key)
 canonicalize_key returns the canonical form of the header key 'key'. More...
 

Detailed Description

The Header class encapsulates the headers of an HTTP request/response.

Definition at line 38 of file header.h.

Constructor & Destructor Documentation

◆ ~Header()

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

Member Function Documentation

◆ add()

virtual void core::net::http::Header::add ( const std::string &  key,
const std::string &  value 
)
virtual

add adds the given value for the given key to the header.

◆ canonicalize_key()

static std::string core::net::http::Header::canonicalize_key ( const std::string &  key)
static

canonicalize_key returns the canonical form of the header key 'key'.

The canonicalization converts the first letter and any letter following a hyphen to upper case; the rest are converted to lowercase. For example, the canonical key for "accept-encoding" is "Accept-Encoding".

Parameters
keyThe key to be canonicalized.

◆ enumerate()

virtual void core::net::http::Header::enumerate ( const std::function< void(const std::string &, const std::set< std::string > &)> &  enumerator) const
virtual

enumerate iterates over the known fields and invokes the given enumerator for each of them.

◆ has() [1/2]

virtual bool core::net::http::Header::has ( const std::string &  key) const
virtual

has checks if the header contains any entry for the given key.

Parameters
keyThe key into the header map.

◆ has() [2/2]

virtual bool core::net::http::Header::has ( const std::string &  key,
const std::string &  value 
) const
virtual

has checks if the header contains an entry for the given key with the given value.

Parameters
keyThe key into the header map.
valueThe value to check for.

◆ remove() [1/2]

virtual void core::net::http::Header::remove ( const std::string &  key)
virtual

remove erases all values for the given key from the header.

◆ remove() [2/2]

virtual void core::net::http::Header::remove ( const std::string &  key,
const std::string &  value 
)
virtual

remove erases the given value for the given key from the header.

◆ set()

virtual void core::net::http::Header::set ( const std::string &  key,
const std::string &  value 
)
virtual

set assigns the given value to the entry with key 'key' and replaces any previous value.


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