dbp::http_header Class Reference

HTTP header. More...

#include <http_header.h>

Inheritance diagram for dbp::http_header:
Inheritance graph
[legend]

List of all members.

Public Types

typedef std::map< std::string,
std::string > 
http_headers
 HTTP header and value pair collection.

Public Member Functions

 http_header ()
 Constructor.
void set_header (const std::string &key, const std::string &value)
 Initialize a header.
void set_header (const std::string &header)
 Initialize a header.
const std::string & get_header (const std::string &key) const
 Get the header value.
const http_headersall_headers () const
 Get iterator to the all headers.
void set_content (const std::string &value)
 Initialize the content.
void set_content (int value_size, const char *value)
 Initialize the content.
void add_content (int value_size, std::istream &value)
 Append the content.
void add_content (std::istream &value)
 Append the content.
const char * get_content () const
 Get content.
int get_content_size () const
 Get content size.
const std::string get_content_type () const
 Get content type.
void set_content_type (const std::string &value)
 Set content type.
const std::string & http_version () const
 Get HTTP version number.
http_headerhttp_version (const std::string &value)
 Set HTTP version number.
const http_cookies & get_cookies () const
 Return cookies.
void set_cookies (const http_cookies &)
 Set cookies.
void set_cookie (const http_cookie &)
 Clear cookies and set single cookie.
void add_cookie (const http_cookie &)
 Add the cookie.

Protected Attributes

http_headers headers
http_cookies cookies

Friends

std::istream & operator>> (std::istream &, http_header &)
 Set content from a stream.
std::ostream & operator<< (std::ostream &, const http_header &)
 Get a stream from content.

Detailed Description

HTTP header.

This class represents http headers.


Member Function Documentation

void dbp::http_header::add_content ( std::istream &  value  ) 

Append the content.

Detect size of the source stream and add whole content from the source to the content buffer.

Parameters:
value a stream to set content from.
void dbp::http_header::add_content ( int  value_size,
std::istream &  value 
)

Append the content.

Add content from the source stream.

Parameters:
value_size the content size.
value a stream to set content from.
const http_headers& dbp::http_header::all_headers (  )  const [inline]

Get iterator to the all headers.

Obtaining a const_iterator to the all headers added before.

Returns:
a reference to the collection of http headers.
const char* dbp::http_header::get_content (  )  const [inline]

Get content.

Returns:
a pointer to the content.
int dbp::http_header::get_content_size (  )  const [inline]

Get content size.

Returns:
content length in bytes
const std::string dbp::http_header::get_content_type (  )  const [inline]

Get content type.

Returns:
MIME content type
const std::string& dbp::http_header::get_header ( const std::string &  key  )  const

Get the header value.

Get a header value specified by key.

Parameters:
key a value key.
Returns:
a header value.
void dbp::http_header::set_content ( int  value_size,
const char *  value 
)

Initialize the content.

Parameters:
value_size a string length.
value a C string to set as content.
void dbp::http_header::set_content ( const std::string &  value  ) 

Initialize the content.

Parameters:
value a string to set as content.
void dbp::http_header::set_content_type ( const std::string &  value  )  [inline]

Set content type.

Parameters:
value the MIME content type
void dbp::http_header::set_header ( const std::string &  header  ) 

Initialize a header.

Parse a given string (specified by a standard web header, where header and its value are divided by a semicolon). Set up a header and initialize it with parsed value.

Parameters:
header a "header: value" pair.
void dbp::http_header::set_header ( const std::string &  key,
const std::string &  value 
)

Initialize a header.

Set up a header and initialize it with value.

Parameters:
key a header to be initialized.
value a header value.

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

 
Support This Project
SourceForge.net Logo