Main Page | Namespace List | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

NEnvironment.h File Reference

Methods to provide access to environment variables associated with a CGI request. More...

#include <string>
#include <map>

Include dependency graph for NEnvironment.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Namespaces

namespace  monsterworks
namespace  monsterworks::cgi
namespace  monsterworks::cgi::NEnvironment

Typedefs

typedef std::map< EKeys, std::string > Variables
 maps the EKey to the enviornment name

Enumerations

enum  EKeys {
  EKey_ServerName, EKey_ServerSoftware, EKey_ServerAddress, EKey_ServerSignature,
  EKey_ServerProtocol, EKey_ServerPort, EKey_ServerAdministrator, EKey_GatewayInterface,
  EKey_DocumentRoot, EKey_ExecutablePath, EKey_ScriptURI, EKey_ScriptName,
  EKey_ScriptURL, EKey_ScriptFilename, EKey_RequestURI, EKey_RequestMethod,
  EKey_ContentType, EKey_ContentLength, EKey_QueryString, EKey_PathInformation,
  EKey_PathTranslated, EKey_RemoteHost, EKey_RemoteAddress, EKey_RemoteIdentity,
  EKey_RemotePort, EKey_AuthenticationType, EKey_RemoteUser, EKey_HTTPUserAgent,
  EKey_HTTPAccept, EKey_HTTPHost, EKey_HTTPAcceptEncoding, EKey_HTTPConnection,
  EKey_HTTPAcceptLanguage
}
 Various common environment variables. More...

Functions

std::string GetValue (EKeys inKey)
 returns the value of an environment variable based on the key
std::string GetValue (const std::string &inName)
 returns the value of an environment variable based on the name
bool IsPostMethod ()
 returns true if the request method was of type POST
bool IsGetMethod ()
 returns true if the request method was of type GET
const VariablesGetVariables ()
 returns all the EKey/Name pairs known


Detailed Description

Methods to provide access to environment variables associated with a CGI request.

Author
eeyore
Date
2004/03/04 02:51:26

Copyright (c) 2004 eeyore@monsterworks.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 2.

This program is distributed in the hope that it wil be found useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MECHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Gnu Public License in the documentation or read the source of MonsterworksCopyright.h.

You should have received a copy of the GNU General Public Licence along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307 USA.

Definition in file NEnvironment.h.


Typedef Documentation

typedef std::map<EKeys,std::string> monsterworks::cgi::NEnvironment::Variables
 

maps the EKey to the enviornment name

Definition at line 94 of file NEnvironment.h.


Enumeration Type Documentation

enum EKeys
 

Various common environment variables.

These keys were chosen based on what my web server (Apache) was passing to my CGIs and what I use. Many of these are described in files at http://cgi-spec.golux.com/ on the web.

Enumeration values:
EKey_ServerName  The server's hostname, DNS alias or IP address.
EKey_ServerSoftware  Server software responding to the request, format: name/version.
EKey_ServerAddress  The server's address.
EKey_ServerSignature  The server's signature.
EKey_ServerProtocol  The server protocol responding to the request, format: protocol/version.
EKey_ServerPort  The port number to which the request was sent.
EKey_ServerAdministrator  The server's administrator.
EKey_GatewayInterface  The gateway interface and version of the request, format: CGI/version.
EKey_DocumentRoot  Where documents are located on the server.
EKey_ExecutablePath  Path to executables on the server.
EKey_ScriptURI  The URI of the script.
EKey_ScriptName  The virtual path to the executable.
EKey_ScriptURL  The URL of the script.
EKey_ScriptFilename  The filename of the script.
EKey_RequestURI  The URI in the original request.
EKey_RequestMethod  The method of the request, e.g., POST, HEAD, GET, PUT.
EKey_ContentType  The type of the data sent in, for example, a POST or PUT request.
EKey_ContentLength  The length of the data sent in, for example, a POST or PUT request.
EKey_QueryString  The query string which is not decoded.
EKey_PathInformation  Any extra path information sent with the request.
EKey_PathTranslated  The PathInformation converted from virtual-to-physical mapping.
EKey_RemoteHost  The hostname making the request.
EKey_RemoteAddress  The IP address of the remote host making the request.
EKey_RemoteIdentity  The remote username retrieved from the server.
EKey_RemotePort  The port used in the original request.
EKey_AuthenticationType  The type of authentication being used to validate the user.
EKey_RemoteUser  The username for an authenticated user.
EKey_HTTPUserAgent  The user agent in HTTP request, format: software/version library/version.
EKey_HTTPAccept  The content types the user is willing to accept, format: type/subtype, type/subtype, ....
EKey_HTTPHost  The host in the HTTP request.
EKey_HTTPAcceptEncoding  Encodings we're willing to accept.
EKey_HTTPConnection  Type of connection.
EKey_HTTPAcceptLanguage  Languages we're willing to accept.
Definition at line 42 of file NEnvironment.h.


Function Documentation

std::string monsterworks::cgi::NEnvironment::GetValue const std::string &  inName  ) 
 

returns the value of an environment variable based on the name

Returns the value of a environment variable given the variables name.

Returns:
the value of the environment variable. It will return the empty string if the variable is not found.
Parameters:
inName  the name of the environment variable we want.
Definition at line 62 of file NEnvironment.cp.

References monsterworks::cgi::NCapture::GetEnvironmentVariable(), and NEnvironmentInitialize().

Referenced by monsterworks::cgi::NEnvironment::IsGetMethod(), monsterworks::cgi::NEnvironment::IsPostMethod(), and NFormInitialize().

std::string monsterworks::cgi::NEnvironment::GetValue EKeys  inKey  ) 
 

returns the value of an environment variable based on the key

Returns the value of an environment variable given the variables key. It asserts that the variable key is in the ourKeyStrings mapping and will fail if it is missing.

Returns:
the value of the environment variable. It will return the empty string if the variable is not found.
Parameters:
inKey  the key associated with the variable
Definition at line 78 of file NEnvironment.cp.

References NEnvironmentInitialize(), and ourKeyStrings.

const monsterworks::cgi::NEnvironment::Variables & monsterworks::cgi::NEnvironment::GetVariables  ) 
 

returns all the EKey/Name pairs known

Returns all of the EKeys to variable name mappings. Can be used to iterate through all known environment variables.

Returns:
the variables in a Variables format.
Definition at line 50 of file NEnvironment.cp.

References NEnvironmentInitialize(), and ourKeyStrings.

bool monsterworks::cgi::NEnvironment::IsGetMethod  ) 
 

returns true if the request method was of type GET

Returns true if the request method was a GET method.

Returns:
true if the request was a GET request and false otherwise.
Definition at line 107 of file NEnvironment.cp.

References monsterworks::cgi::NEnvironment::GetValue(), and NEnvironmentInitialize().

bool monsterworks::cgi::NEnvironment::IsPostMethod  ) 
 

returns true if the request method was of type POST

Returns true the request method was a POST method.

Returns:
true if the request was a POST request and false otherwise.
Definition at line 96 of file NEnvironment.cp.

References monsterworks::cgi::NEnvironment::GetValue(), and NEnvironmentInitialize().


monsterworks Code by Monsterworks. Made available under the GNU Public License.
Documentation by doxygen.