Main Page | Compound List | Compound Members

cgixx::header Class Reference

#include <header.h>

List of all members.

Public Member Functions

 header ()
 ~header ()
void setlength (unsigned length)
 Set Content-length header.

void settype (const std::string &contenttype)
 Set Content-type header.

bool setexpire (const std::string &expire)
 Set Expire header.

void setstatus (unsigned status, const std::string &description="")
 Set Status Code.

void override (const std::string &httpversion="HTTP/1.0")
 Override the web server's parsing of headers.

void setheader (const std::string &id, const std::string &value)
 Set a generic header.

void redirect (const std::string &location)
 Create a redirect header.

void addcookie (cookie &value)
 Add a cookie object to the header.

std::string get () const
 Get the formatted header string.


Detailed Description

The header class is used to generate valid HTTP headers to be sent to the web client. If no modifing methos are accessed, a default header of:

400 OK Content-type: text/html

will be generated. The get method returns the header string.

Author:
Isaac W. Foraker


Constructor & Destructor Documentation

cgixx::header::header  ) 
 

Construct a header object.

cgixx::header::~header  ) 
 

Destroy *this header object.


Member Function Documentation

void cgixx::header::addcookie cookie value  ) 
 

Add a cookie object to the header.

Add a cookie to the header.

Parameters:
value Reference to completed cookie.
Returns:
nothing

std::string cgixx::header::get  )  const
 

Get the formatted header string.

Get the formatted CGI HTTP header to send to the client. The default header will be

400 OK Content-type: text/html

unless modified by other header methods. The web server may modify or expand on these headers unless a specific status code has been specified (e.g. through redirect method).

Returns:
The header string.

void cgixx::header::override const std::string &  httpversion = "HTTP/1.0"  ) 
 

Override the web server's parsing of headers.

Set the HTTP version string, overriding the web servers processing of the HTTP headers returned by this program.

Parameters:
httpversion The HTTP version string (e.g. HTTP/1.1).
Returns:
nothing

void cgixx::header::redirect const std::string &  location  ) 
 

Create a redirect header.

Create a redirect header.

Parameters:
location Path or URL to redirect to.
Returns:
nothing

bool cgixx::header::setexpire const std::string &  expire  ) 
 

Set Expire header.

Set the expiration date for the document.

Parameters:
expire The expire parameter my be either the RFC 850 encoded date of expiration, or an offset string containing "(-)123(M|H|S|D|W|m|Y)". I.e. a number (negative numbers generally cause the document to expire immediately) followed by a time modifier. M=minute, H=hour, S=second, D=day, W=week, m=month, Y=year.
Returns:
false if the offset was successfully parsed into a date;

true if the the expire string was accepted as is.

void cgixx::header::setheader const std::string &  id,
const std::string &  value
 

Set a generic header.

Set a user-defined HTTP header.

Parameters:
id Identifier for header.
value Value of header.
Returns:
nothing

void cgixx::header::setlength unsigned  length  ) 
 

Set Content-length header.

Set the content length to be sent to the client.

Parameters:
length The content length.
Returns:
nothing

void cgixx::header::setstatus unsigned  status,
const std::string &  description = ""
 

Set Status Code.

Set the status code to be returned to the client. Manually setting the status code will override the web server's ability to alter HTTP headers.

Parameters:
status Desired Status code.
description Optional description for status. If no description is specified, a default is supplied based on the status code.
Returns:
nothing.

void cgixx::header::settype const std::string &  contenttype  ) 
 

Set Content-type header.

Set the mime type of the content to be sent to the client. This is only required if content other than HTML is being returned. Format: type/sub-type

Parameters:
contenttype The content mime type (e.g. image/jpg).
Returns:
nothing


The documentation for this class was generated from the following files:
Generated on Fri Feb 6 16:05:31 2004 for cgixx by doxygen 1.3.3