restcgi::hdr Class Reference

Inheritance diagram for restcgi::hdr:

restcgi::content_hdr restcgi::general_hdr restcgi::request_hdr restcgi::response_hdr List of all members.

Detailed Description

HTTP header base class mapping field names to values.

Notes:

See also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html


Public Types

typedef std::map< key, std::string > map_type
 map type
typedef map_type::const_iterator const_iterator
 const iterator
 fc_null
 none
 fc_general = 1<<0
 general fields
 fc_request = 1<<1
 request fields
 fc_response = 1<<2
 response fields
 fc_other = 1<<3
 other fields
 fc_entity_rsp = 1<<4
 entity response fields
 fc_entity_cnt = 1<<5
 entity content fields
enum  fld_category {
  fc_null, fc_general = 1<<0, fc_request = 1<<1, fc_response = 1<<2,
  fc_other = 1<<3, fc_entity_rsp = 1<<4, fc_entity_cnt = 1<<5
}
 Field category enumeration. IN TRANSMISSION ORDER!!! More...

Public Member Functions

virtual ~hdr ()
 Destruct.
bool empty () const
 Test if empty.
const_iterator begin () const
 Get map beginning.
const_iterator end () const
template<typename T>
bool insert (const std::string &name, const T &value)
template<typename T>
bool find (const std::string &name, T &value) const
bool erase (const std::string &name)
std::ostream & operator<< (std::ostream &os) const
 Stream out in HTTP header format.

Static Public Member Functions

static const fld_traitsfind_fld_traits (const std::string &lower_name)
 Find standard field traits from lower-case name, returning 0 if not found.

Static Public Attributes

static const char FLD_NAME_END_CHAR
 field name end char (':')
static const char EOL_CSTR [3]
 end-of-line ("\r\n")

Protected Member Functions

 hdr (int categories)
 Construct.
bool insert (int fld_traits_off, const std::string &v)
 Insert.
bool insert (const key &k, const std::string &value, bool update=false)
 Insert.
std::string find (int fld_traits_off) const
 Find.
virtual void on_inserted (const_iterator it)
 Inserted notification.

Static Protected Member Functions

static void throw_bad_request (const char *name, const char *what)
 Throw bad request.

Protected Attributes

const int categories_
 categories

Friends

void RESTCGI_API copy (const env &e, request_hdr &rh, content_hdr &ch)
 Copy the request and content headers from the environment.

Classes

class  fld_traits
 Traits for the standard fields. More...
class  key
 Key for field-to-value map. More...


Member Enumeration Documentation

enum restcgi::hdr::fld_category

Field category enumeration. IN TRANSMISSION ORDER!!!

Enumerator:
fc_null  none
fc_general  general fields
fc_request  request fields
fc_response  response fields
fc_other  other fields
fc_entity_rsp  entity response fields
fc_entity_cnt  entity content fields


Member Function Documentation

const_iterator restcgi::hdr::end (  )  const [inline]

Get map end.

bool restcgi::hdr::erase ( const std::string &  name  ) 

Erase field, returning whether successful.

template<typename T>
bool restcgi::hdr::find ( const std::string &  name,
T &  value 
) const [inline]

Find the field returning the typed value and whether found. Works with both standard and "other" fields. The name is case insensitive on lookup.

Exceptions:
bad_request if conversion error

template<typename T>
bool restcgi::hdr::insert ( const std::string &  name,
const T &  value 
) [inline]

Insert the field into the header, returning whether it was inserted or not. Fields are not overwritten if already in the header or the insert value is empty. Works for both standard fields and "other" fields. The name is case insensitive on lookup.

Returns:
false if exists, invalid category or name or value empty


Friends And Related Function Documentation

void RESTCGI_API copy ( const env e,
request_hdr rh,
content_hdr ch 
) [friend]

Copy the request and content headers from the environment.

Note that the "general" and "other" fields are put into the request hdr, only content-specific ones are put in the content hdr.


Generated on Fri May 15 11:27:12 2009 for restcgi by  doxygen 1.4.7