cgicc::CgiEnvironment Class Reference

Class encapsulating the CGI runtime environment. More...

#include <cgicc/CgiEnvironment.h>

List of all members.

Public Member Functions

Overloaded Operators
bool operator== (const CgiEnvironment &env) const
 Compare two CgiEnvironments for equality.
bool operator!= (const CgiEnvironment &env) const
 Compare two CgiEnvironments for inequality.
CgiEnvironmentoperator= (const CgiEnvironment &env)
 Assign one CgiEnvironment to another.
Server Information
Information on the server handling the HTTP/CGI request

std::string getServerSoftware () const
 Get the name and version of the HTTP server software.
std::string getServerName () const
 Get the hostname, DNS name or IP address of the HTTP server.
std::string getGatewayInterface () const
 Get the name and version of the gateway interface.
std::string getServerProtocol () const
 Get the name and revision of the protocol used for this request.
unsigned long getServerPort () const
 Get the port number on the server to which this request was sent.
bool usingHTTPS () const
 Determine if this is a secure request.
CGI Query Information
Information specific to this CGI query

std::string getCookies () const
 Get the HTTP cookies associated with this query, if any.
const std::vector< HTTPCookie > & getCookieList () const
 Get a vector containing the HTTP cookies associated with this query.
std::string getRequestMethod () const
 Get the request method used for this query.
std::string getPathInfo () const
 Get the extra path information for this request, given by the client.
std::string getPathTranslated () const
 Get the translated path information (virtual to physical mapping).
std::string getScriptName () const
 Get the full path to this CGI application.
std::string getQueryString () const
 Get the query string for this request.
unsigned long getContentLength () const
 Get the length of the data read from standard input, in chars.
std::string getContentType () const
 Get the content type of the submitted information.
std::string getPostData () const
 Get the data passed to the CGI application via standard input.
Server Specific Information
Information dependent on the type of HTTP server in use

std::string getReferrer () const
 Get the URL of the page which called this CGI application.
Remote User Information
Information about the user making the CGI request

std::string getRemoteHost () const
 Get the hostname of the remote machine making this request.
std::string getRemoteAddr () const
 Get the IP address of the remote machine making this request.
std::string getAuthType () const
 Get the protocol-specific user authentication method used.
std::string getRemoteUser () const
 Get the authenticated remote user name.
std::string getRemoteIdent () const
 Get the remote user name retrieved from the server.
std::string getAccept () const
 Get the MIME data types accepted by the client's browser.
std::string getUserAgent () const
 Get the name of the browser used for this CGI request.
ErrorDocument Handling
For a tutorial on ErrorDocument handling, see http://hoohoo.ncsa.uiuc.edu/cgi/ErrorCGI.html

std::string getRedirectRequest () const
 Get the redirect request.
std::string getRedirectURL () const
 Get the redirect URL.
std::string getRedirectStatus () const
 Get the redirect status.

Protected Member Functions

Saving and Restoring
These are implementation methods only

void save (const std::string &filename) const
 Implementation of save, for saving CGI environments.
void restore (const std::string &filename)
 Implementation of restore, for restoring CGI environments.

Friends

class Cgicc


Detailed Description

Class encapsulating the CGI runtime environment.

The CgiEnvironment class encapsulates the environment of the CGI application as described by the HTTP server. CgiEnvironment contains the GET or POST data along with all environment variables set by the HTTP server specified in the CGI specification.

Definition at line 76 of file CgiEnvironment.h.


Constructor & Destructor Documentation

cgicc::CgiEnvironment::CgiEnvironment ( CgiInput input  ) 

Read in the CGI environment passed to the CGI application by the server.

This function is not usually called directly; instead, an object of type CgiEnvironment is retrieved by calling the getEnvironment() method on Cgicc. If you are using cgicc with FastCGI, you will need to pass a CgiInput subclass that cgicc will use to read input. If input is omitted, standard input and environment variables will be used.

Parameters:
input A CgiInput object to use for reading input
See also:
Cgicc::getEnvironment

cgicc::CgiEnvironment::CgiEnvironment ( const CgiEnvironment env  )  [inline]

Copy constructor.

Sets the values of this CgiEnvironment to those of env.

Parameters:
env The CgiEnvironment to copy.

Definition at line 110 of file CgiEnvironment.h.

cgicc::CgiEnvironment::~CgiEnvironment (  ) 

Destructor.

Delete this CgiEnvironment object

cgicc::CgiEnvironment::CgiEnvironment ( CgiInput input  ) 

Read in the CGI environment passed to the CGI application by the server.

This function is not usually called directly; instead, an object of type CgiEnvironment is retrieved by calling the getEnvironment() method on Cgicc. If you are using cgicc with FastCGI, you will need to pass a CgiInput subclass that cgicc will use to read input. If input is omitted, standard input and environment variables will be used.

Parameters:
input A CgiInput object to use for reading input
See also:
Cgicc::getEnvironment

cgicc::CgiEnvironment::CgiEnvironment ( const CgiEnvironment env  )  [inline]

Copy constructor.

Sets the values of this CgiEnvironment to those of env.

Parameters:
env The CgiEnvironment to copy.

Definition at line 110 of file CgiEnvironment.h.

cgicc::CgiEnvironment::~CgiEnvironment (  ) 

Destructor.

Delete this CgiEnvironment object


Member Function Documentation

bool cgicc::CgiEnvironment::operator== ( const CgiEnvironment env  )  const

Compare two CgiEnvironments for equality.

CgiEnvironments are equal if they have the same environment variables.

Parameters:
env The CgiEnvironment to compare to this one.
Returns:
true if the two CgiEnvironments are equal, false otherwise.

bool cgicc::CgiEnvironment::operator!= ( const CgiEnvironment env  )  const [inline]

Compare two CgiEnvironments for inequality.

CgiEnvironments are equal if they have the same environment variables.

Parameters:
env The CgiEnvironment to compare to this one.
Returns:
false if the two CgiEnvironments are equal, true otherwise.

Definition at line 144 of file CgiEnvironment.h.

CgiEnvironment& cgicc::CgiEnvironment::operator= ( const CgiEnvironment env  ) 

Assign one CgiEnvironment to another.

Sets the environment variables in this CgiEnvironment to those of env.

Parameters:
env The CgiEnvironment to copy.
Returns:
A reference to this.

std::string cgicc::CgiEnvironment::getServerSoftware (  )  const [inline]

Get the name and version of the HTTP server software.

For example, Apache/1.3.4

Returns:
The name of the server software

Definition at line 179 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getServerName (  )  const [inline]

Get the hostname, DNS name or IP address of the HTTP server.

This is not a URL, for example www.gnu.org (no leading http://)

Returns:
The name of the server

Definition at line 189 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getGatewayInterface (  )  const [inline]

Get the name and version of the gateway interface.

This is usually CGI/1.1

Returns:
The name and version of the gateway interface

Definition at line 199 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getServerProtocol (  )  const [inline]

Get the name and revision of the protocol used for this request.

This is usually HTTP/1.0 or HTTP/1.1

Returns:
The protocol in use

Definition at line 209 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

unsigned long cgicc::CgiEnvironment::getServerPort (  )  const [inline]

Get the port number on the server to which this request was sent.

This will usually be 80.

Returns:
The port number

Definition at line 219 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

bool cgicc::CgiEnvironment::usingHTTPS (  )  const [inline]

Determine if this is a secure request.

A secure request is usually made using SSL via HTTPS

Returns:
true if this connection is via https, false otherwise

Definition at line 229 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getCookies (  )  const [inline]

Get the HTTP cookies associated with this query, if any.

The string returned by this method may contain multiple cookies; it is recommended to use the method getCookieList() instead, which returns a vector<HTTPCookie>.

Returns:
The HTTP cookies
See also:
getCookieList

Definition at line 250 of file CgiEnvironment.h.

Referenced by dumpEnvironment(), and main().

const std::vector<HTTPCookie>& cgicc::CgiEnvironment::getCookieList (  )  const [inline]

Get a vector containing the HTTP cookies associated with this query.

This vector may be empty

Returns:
A vector containing the HTTP cookies associated with this query
See also:
HTTPCookie

Definition at line 263 of file CgiEnvironment.h.

Referenced by main().

std::string cgicc::CgiEnvironment::getRequestMethod (  )  const [inline]

Get the request method used for this query.

This is usually one of GET or POST

Returns:
The request method

Definition at line 273 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getPathInfo (  )  const [inline]

Get the extra path information for this request, given by the client.

For example, in the string foo.cgi/cgicc the path information is cgicc.

Returns:
The absolute path info

Definition at line 285 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getPathTranslated (  )  const [inline]

Get the translated path information (virtual to physical mapping).

For example, www.gnu.org may be translated to /htdocs/index.html

Returns:
The translated path info

Definition at line 295 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getScriptName (  )  const [inline]

Get the full path to this CGI application.

This is useful for self-referencing URIs

Returns:
The full path of this application

Definition at line 305 of file CgiEnvironment.h.

Referenced by dumpEnvironment(), main(), and printForm().

std::string cgicc::CgiEnvironment::getQueryString (  )  const [inline]

Get the query string for this request.

The query string follows the ? in the URI which called this application. This is usually only valid for scripts called with the GET method. For example, in the string foo.cgi?cgicc=yes the query string is cgicc=yes.

Returns:
The query string

Definition at line 318 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

unsigned long cgicc::CgiEnvironment::getContentLength (  )  const [inline]

Get the length of the data read from standard input, in chars.

This is usually only valid for scripts called with the POST method.

Returns:
The data length

Definition at line 328 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getContentType (  )  const [inline]

Get the content type of the submitted information.

For applications called via the GET method, this information is irrelevant. For applications called with the POST method, this is specifies the MIME type of the information, usually application/x-www-form-urlencoded or as specified by getContentType().

Returns:
The content type
See also:
getContentType

Definition at line 343 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getPostData (  )  const [inline]

Get the data passed to the CGI application via standard input.

This data is of MIME type getContentType().

Returns:
The post data.

Definition at line 353 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getReferrer (  )  const [inline]

Get the URL of the page which called this CGI application.

Depending on the HTTP server software, this value may not be set.

Returns:
The URI which called this application.

Definition at line 371 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getRemoteHost (  )  const [inline]

Get the hostname of the remote machine making this request.

This may be either an IP address or a hostname

Returns:
The remote host

Definition at line 389 of file CgiEnvironment.h.

Referenced by dumpEnvironment(), and main().

std::string cgicc::CgiEnvironment::getRemoteAddr (  )  const [inline]

Get the IP address of the remote machine making this request.

This is a standard IP address of the form 123.123.123.123

Returns:
The remote IP address

Definition at line 399 of file CgiEnvironment.h.

Referenced by dumpEnvironment(), and main().

std::string cgicc::CgiEnvironment::getAuthType (  )  const [inline]

Get the protocol-specific user authentication method used.

This is only applicable if the server supports user authentication, and the user has authenticated.

Returns:
The authorization type

Definition at line 410 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getRemoteUser (  )  const [inline]

Get the authenticated remote user name.

This is only applicable if the server supports user authentication, and the user has authenticated.

Returns:
The remote username

Definition at line 421 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getRemoteIdent (  )  const [inline]

Get the remote user name retrieved from the server.

This is only applicable if the server supports RFC 931 identification. This variable should only be used for logging purposes.

Returns:
The remote identification
See also:
RFC 1431 at http://info.internet.isi.edu:80/in-notes/rfc/files/rfc1413.txt

Definition at line 435 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getAccept (  )  const [inline]

Get the MIME data types accepted by the client's browser.

For example image/gif, image/x-xbitmap, image/jpeg, image/pjpeg

Returns:
The accepted data types

Definition at line 445 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getUserAgent (  )  const [inline]

Get the name of the browser used for this CGI request.

For example Mozilla/5.0 (X11; U; Linux 2.4.0 i686; en-US; 0.8.1) Gecko/20010421

Returns:
The browser name

Definition at line 456 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getRedirectRequest (  )  const [inline]

Get the redirect request.

This will only be valid if you are using this script as a script to use in place of the default server messages.

Returns:
The redirect request.

Definition at line 476 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getRedirectURL (  )  const [inline]

Get the redirect URL.

This will only be valid if you are using this script as a script to use in place of the default server messages.

Returns:
The redirect URL.
See also:
http://hoohoo.ncsa.uiuc.edu/docs/setup/srm/ErrorDocument.html

Definition at line 488 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

std::string cgicc::CgiEnvironment::getRedirectStatus (  )  const [inline]

Get the redirect status.

This will only be valid if you are using this script as a script to use in place of the default server messages.

Returns:
The redirect status.

Definition at line 499 of file CgiEnvironment.h.

Referenced by dumpEnvironment().

void cgicc::CgiEnvironment::save ( const std::string &  filename  )  const [protected]

Implementation of save, for saving CGI environments.

This is called internally by Cgicc

Parameters:
filename The name of the file to which to save

void cgicc::CgiEnvironment::restore ( const std::string &  filename  )  [protected]

Implementation of restore, for restoring CGI environments.

This is called internally by Cgicc

Parameters:
filename The name of the file from which to restore


The documentation for this class was generated from the following file:
GNU cgicc - A C++ class library for writing CGI applications
Copyright © 1996 - 2004 Stephen F. Booth
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front Cover Texts, and with no Back-Cover Texts.
Documentation generated Sat Jan 19 21:16:00 2008 for cgicc by doxygen 1.5.1