atscppapi  1.0.9
C++ wrapper for Apache Traffic Server API
 All Classes Files Functions Enumerations Enumerator Macros
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
atscppapi::Headers Class Reference

Encapsulates the headers portion of a request or response. More...

#include "Headers.h"

Inherits atscppapi::noncopyable.

Classes

struct  ResponseCookie
 

Public Types

enum  Type { TYPE_REQUEST, TYPE_RESPONSE }
 
typedef std::map< std::string,
std::list< std::string >
, CaseInsensitiveStringComparator
NameValuesMap
 
typedef NameValuesMap::size_type size_type
 
typedef
NameValuesMap::const_iterator 
const_iterator
 
typedef
NameValuesMap::const_reverse_iterator 
const_reverse_iterator
 
typedef std::map< std::string,
std::list< std::string > > 
RequestCookieMap
 

Public Member Functions

 Headers (Type type=TYPE_REQUEST)
 
Type getType () const
 
const_iterator begin () const
 
const_iterator end () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
const_iterator find (const std::string &key) const
 
size_type count (const std::string &key) const
 
size_type erase (const std::string &key)
 
const_iterator set (const std::pair< std::string, std::list< std::string > > &pair)
 
const_iterator set (const std::string &key, const std::list< std::string > &val)
 
const_iterator set (const std::string &key, const std::string &val)
 
const_iterator append (const std::pair< std::string, std::list< std::string > > &pair)
 
const_iterator append (const std::string &key, const std::list< std::string > &val)
 
const_iterator append (const std::string &key, const std::string &val)
 
std::string getJoinedValues (const std::string &key, char value_delimiter= ',')
 
bool empty () const
 
size_type max_size () const
 
size_type size () const
 
const RequestCookieMap & getRequestCookies () const
 
const std::list< ResponseCookie > & getResponseCookies () const
 
bool addCookie (const std::string &name, const std::string &value)
 
bool addCookie (const ResponseCookie &response_cookie)
 
bool setCookie (const std::string &name, const std::string &value)
 
bool setCookie (const ResponseCookie &response_cookie)
 
bool deleteCookie (const std::string &name)
 

Static Public Member Functions

static std::string getJoinedValues (const std::list< std::string > &values, char delimiter= ',')
 

Detailed Description

Encapsulates the headers portion of a request or response.

Member Function Documentation

bool atscppapi::Headers::addCookie ( const std::string &  name,
const std::string &  value 
)

Adds a request cookie

bool Headers::addCookie ( const ResponseCookie response_cookie)

Adds a response cookie

const_iterator atscppapi::Headers::append ( const std::pair< std::string, std::list< std::string > > &  pair)

Appends a new header. If a header of the same name exists, value(s) is tacked on that the end of current value(s).

Parameters
pairContains the name and list of values.
Returns
Iterator to header appended.
const_iterator atscppapi::Headers::append ( const std::string &  key,
const std::list< std::string > &  val 
)

Appends a new header. If a header of the same name exists, value(s) is tacked on that the end of current value(s).

Parameters
keyName of header
valList of values
Returns
Iterator to header appended.
const_iterator atscppapi::Headers::append ( const std::string &  key,
const std::string &  val 
)

Appends a new header. If a header of the same name exists, value(s) is tacked on that the end of current value(s).

Parameters
keyName of header
valValue
Returns
Iterator to header appended.
Headers::const_iterator Headers::begin ( ) const
Returns
Iterator to first header.
Headers::size_type Headers::count ( const std::string &  key) const
Parameters
keyName of header
Returns
1 if header exists, 0 if not.
bool Headers::deleteCookie ( const std::string &  name)

Deletes a cookie

bool Headers::empty ( ) const
Returns
True if there are no headers.
Headers::const_iterator Headers::end ( ) const
Returns
Iterator to end of headers.
Headers::size_type Headers::erase ( const std::string &  key)

Erases header with given name.

Parameters
keyName of header
Returns
1 if header was erased, 0 if not.
Headers::const_iterator Headers::find ( const std::string &  key) const
Parameters
keyName of header
Returns
Iterator to header if exists, else end()
static std::string atscppapi::Headers::getJoinedValues ( const std::list< std::string > &  values,
char  delimiter = ',' 
)
static

Joins provided list of values with delimiter (defaulting to ',').

Returns
Composite string
std::string atscppapi::Headers::getJoinedValues ( const std::string &  key,
char  value_delimiter = ',' 
)

Joins values of provided header with delimiter (defaulting to ',').

Returns
Composite string if header exists, else empty strings.
const Headers::RequestCookieMap & Headers::getRequestCookies ( ) const
Returns
Cookies in the "Cookie" headers of a request object.
const list< Headers::ResponseCookie > & Headers::getResponseCookies ( ) const
Returns
Cookies in the "Set-Cookie" headers of a response object.
Headers::size_type Headers::max_size ( ) const
Returns
Largest possible size of underlying map.
Headers::const_reverse_iterator Headers::rbegin ( ) const
Returns
Iterator to last header.
Headers::const_reverse_iterator Headers::rend ( ) const
Returns
Iterator to "reverse end"
const_iterator atscppapi::Headers::set ( const std::pair< std::string, std::list< std::string > > &  pair)

Sets the given header and values. If a header of same name existed, that is deleted. Else header is appended.

Parameters
pairContains the name and list of values.
Returns
Iterator to header set.
const_iterator atscppapi::Headers::set ( const std::string &  key,
const std::list< std::string > &  val 
)

Sets the given header and values. If a header of same name existed, that is deleted. Else header is appended.

Parameters
keyName of header
valList of values
Returns
Iterator to header set.
const_iterator atscppapi::Headers::set ( const std::string &  key,
const std::string &  val 
)

Sets the given header and values. If a header of same name existed, that is deleted. Else header is appended.

Parameters
keyName of header
valValue
Returns
Iterator to header set.
bool atscppapi::Headers::setCookie ( const std::string &  name,
const std::string &  value 
)

Sets, i.e., clears current value and adds new value, of a request cookie

bool Headers::setCookie ( const ResponseCookie response_cookie)

Sets, i.e., clears current value and adds new value, of a response cookie

Headers::size_type Headers::size ( ) const
Returns
Number of headers currently stored.

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