restcgi::env Class Reference

List of all members.

Detailed Description

CGI environment variables.

This pulls the CGI information out of the process environment, e.g. SERVER_PORT. Note that some of this information is stored in the other library classes where appropriate, in particular, the hdr classes.

Example: GET http://mywebserver.com/cgi-bin/mycgi.exe/hello/foo?abc=a%20b%20c

 REQUEST_METHOD=GET
 SCRIPT_URI=http://mywebserver.com/cgi-bin/mycgi.exe/hello/foo
 REQUEST_URI=/cgi-bin/mycgi.exe/hello/foo?abc=a20b20c
 SCRIPT_URL=/cgi-bin/mycgi.exe/hello/foo
 SCRIPT_NAME=/cgi-bin/mycgi.exe
 PATH_INFO=/hello/foo
 QUERY_STRING=abc=a20b20c
 

fcgid_module differences (WINDOWS only):

 SCRIPT_NAME=/cgi-bin
 PATH_INFO=/mycgi.exe/hello/foo
 

Attribution to NCSA Software Development Group, cgi@ncsa.uiuc.edu.

See also:
http://hoohoo.ncsa.uiuc.edu/cgi/env.html

hdr


Public Types

typedef std::map< std::string,
std::string > 
map_type

Public Member Functions

 env ()
 Construct.
 env (const char **pcstr)
 Construct from null-terminated array of strings (for testing).
 env (const map_type &m)
 Construct from map (for testing).
std::string server_software () const
std::string server_name () const
std::string gateway_interface () const
std::string server_protocol () const
std::string server_port () const
 The port number to which the request was sent.
std::string request_method () const
std::string path_info () const
std::string path_translated () const
std::string script_name () const
std::string request_uri () const
std::string script_filename () const
std::string script_url () const
std::string script_uri () const
std::string query_string () const
std::string remote_host () const
std::string remote_addr () const
 The IP address of the remote host making the request.
std::string auth_type () const
std::string remote_user () const
std::string remote_ident () const
std::string redirect_request () const
 Error script: This is the request as sent exactly to the server.
std::string redirect_url () const
 Error script: This is the requested URL that caused the error.
std::string redirect_status () const
std::string content_type () const
std::string content_length () const
std::string accept () const
std::string accept_charset () const
std::string accept_encoding () const
std::string accept_language () const
std::string user_agent () const
bool hdr_find (const std::string &hname, std::string &value) const
bool find (const char *name, std::string &value) const
 Find environment variable value, returning value and true if found.
std::string find (const char *name) const
hdr_iterator hdr_begin () const
 Header fields beginning.
hdr_iterator hdr_end () const
void override (const std::string &name, const std::string &value)
 Override name with value. Useful for "preprocessing" of REST input.

Static Public Member Functions

static std::string to_env_name (const std::string &hname)
static std::string from_env_name (const std::string &ename)
 Inverse of to_env_name() returning all lower case and "-"s.

Friends

class hdr_iterator

Classes

class  hdr_iterator
 Iterator over the header field string pairs: name, value. More...


Member Typedef Documentation

typedef std::map<std::string, std::string> restcgi::env::map_type

map type


Member Function Documentation

std::string restcgi::env::accept (  )  const

The MIME types which the client will accept, as given by HTTP headers. Other protocols may need to get this information from elsewhere. Each item in this list should be separated by commas as per the HTTP spec. Format: type/subtype, type/subtype

See also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1

std::string restcgi::env::accept_charset (  )  const

Charsets acceptable for response.

See also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2

std::string restcgi::env::accept_encoding (  )  const

Restricts the content-codings that are acceptable in the response.

See also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3

std::string restcgi::env::accept_language (  )  const

Restricts the set of natural languages that are preferred as a response to the request.

See also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4

std::string restcgi::env::auth_type (  )  const

If the server supports user authentication, and the script is protects, this is the protocol-specific authentication method used to validate the user.

std::string restcgi::env::content_length (  )  const

The length of the said content as given by the client.

See also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13

std::string restcgi::env::content_type (  )  const

For queries which have attached information, such as HTTP POST and PUT, this is the content type of the data.

See also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17

std::string restcgi::env::find ( const char *  name  )  const

Find environment variable value, returning value or empty string if not found.

std::string restcgi::env::gateway_interface (  )  const

The revision of the CGI specification to which this server complies. Format: CGI/revision

hdr_iterator restcgi::env::hdr_end (  )  const [inline]

Header fields end.

bool restcgi::env::hdr_find ( const std::string &  hname,
std::string &  value 
) const

Find HTTP header field value, returning value and true if found. This uses to_env_name() to get the field value from the process env.

std::string restcgi::env::path_info (  )  const

The path information without the script_name() as given by the client. In other words, scripts can be accessed by their virtual pathname, followed by extra information at the end of this path. The extra information is sent as PATH_INFO. This information is decoded by the server if it comes from a URL before it is passed to the CGI script.

See also:
script_name()

std::string restcgi::env::path_translated (  )  const

The server provides a translated version of PATH_INFO, which takes the path and does any virtual-to-physical mapping to it. This is where the document file would have been if the script_name() had not been in the URL (not very useful).

std::string restcgi::env::query_string (  )  const

The information which follows the ? in the URL which referenced this script. This is the query information. It should not be decoded in any fashion. This variable should always be set when there is query information, regardless of command line decoding.

std::string restcgi::env::redirect_status (  )  const

Error script: This is the status number and message that would have been sent if it would have been allowed to reply.

std::string restcgi::env::remote_host (  )  const

The hostname making the request. If the server does not have this information, it should set REMOTE_ADDR and leave this unset.

std::string restcgi::env::remote_ident (  )  const

If the HTTP server supports RFC 931 identification, then this variable will be set to the remote user name retrieved from the server. Usage of this variable should be limited to logging only.

std::string restcgi::env::remote_user (  )  const

If the server supports user authentication, and the script is protected, this is the username they have authenticated as.

std::string restcgi::env::request_method (  )  const

The method with which the request was made. For HTTP, this is "GET", "HEAD", "POST", etc.

std::string restcgi::env::request_uri (  )  const

This is the original script_name() plus path_info() plus query_string().

See also:
script_name()

std::string restcgi::env::script_filename (  )  const

File system path to the script being executed. Note that this is independent of rewrites.

std::string restcgi::env::script_name (  )  const

A virtual path to the script being executed, used for self-referencing URLs. This is the original path before any rewrites, i.e. if rewriting inserts a script name into the path it is not included here. When prefixed to the path_info() gives the script_url().

See also:
path_info()

std::string restcgi::env::script_uri (  )  const

The original URL minus query_string(). In other words, this is script_url() with "http://" and hostname prefixed to it.

See also:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#EnvVar

std::string restcgi::env::script_url (  )  const

The original path, which is path_info() with the original cgi-script name prefixed to it. This is the request_uri() minus the query_string().

See also:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#EnvVar

std::string restcgi::env::server_name (  )  const

The server's hostname, DNS alias, or IP address as it would appear in self-referencing URLs.

std::string restcgi::env::server_protocol (  )  const

The name and revision of the information protcol this request came in with. Format: protocol/revision

std::string restcgi::env::server_software (  )  const

The name and version of the information server software answering the request (and running the gateway). Format: name/version

static std::string restcgi::env::to_env_name ( const std::string &  hname  )  [static]

Uppercase the name, translate "-" to "_" and prefix "HTTP_". This is the format used to store the value in the process environment. For example, the name "content-length" would be translated to HTTP_CONTENT_LENGTH.

std::string restcgi::env::user_agent (  )  const

The browser the client is using to send the request. General format: software/version library/version.

See also:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43


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