#include <cgicc/CgiEnvironment.h>
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. | |
CgiEnvironment & | operator= (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 | |
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 |
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.
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.
input | A CgiInput object to use for reading input |
cgicc::CgiEnvironment::CgiEnvironment | ( | const CgiEnvironment & | env | ) | [inline] |
Copy constructor.
Sets the values of this CgiEnvironment to those of env
.
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.
input | A CgiInput object to use for reading input |
cgicc::CgiEnvironment::CgiEnvironment | ( | const CgiEnvironment & | env | ) | [inline] |
Copy constructor.
Sets the values of this CgiEnvironment to those of env
.
env | The CgiEnvironment to copy. |
Definition at line 110 of file CgiEnvironment.h.
cgicc::CgiEnvironment::~CgiEnvironment | ( | ) |
Destructor.
Delete this CgiEnvironment object
bool cgicc::CgiEnvironment::operator== | ( | const CgiEnvironment & | env | ) | const |
Compare two CgiEnvironments for equality.
CgiEnvironments are equal if they have the same environment variables.
env | The CgiEnvironment to compare to this one. |
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.
env | The CgiEnvironment to compare to this one. |
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
.
env | The CgiEnvironment to copy. |
std::string cgicc::CgiEnvironment::getServerSoftware | ( | ) | const [inline] |
Get the name and version of the HTTP server software.
For example, Apache/1.3.4
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://)
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
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
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.
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
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>
.
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
vector
containing the HTTP cookies associated with this query 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
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
.
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
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
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
.
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.
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().
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()
.
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.
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
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
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.
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.
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.
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
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
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.
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.
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.
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
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
filename | The name of the file from which to restore |