mirror of
https://github.com/sheumann/hush.git
synced 2024-12-21 23:29:34 +00:00
149 lines
5.6 KiB
HTML
149 lines
5.6 KiB
HTML
<html><head><title>CGI Environment Variables</title></head><body><h1><img alt="" src="env_files/CGIlogo.gif"> CGI Environment Variables</h1>
|
|
<hr>
|
|
|
|
<p>
|
|
|
|
In order to pass data about the information request from the server to
|
|
the script, the server uses command line arguments as well as
|
|
environment variables. These environment variables are set when the
|
|
server executes the gateway program. </p><p>
|
|
|
|
</p><hr>
|
|
<h2>Specification</h2>
|
|
|
|
<p>
|
|
The following environment variables are not request-specific and are
|
|
set for all requests: </p><p>
|
|
|
|
</p><ul>
|
|
<li> <code>SERVER_SOFTWARE</code> <p>
|
|
|
|
The name and version of the information server software answering
|
|
the request (and running the gateway). Format: name/version </p><p>
|
|
|
|
</p></li><li> <code>SERVER_NAME</code> <p>
|
|
The server's hostname, DNS alias, or IP address as it would appear
|
|
in self-referencing URLs. </p><p>
|
|
|
|
</p></li><li> <code>GATEWAY_INTERFACE</code> <p>
|
|
The revision of the CGI specification to which this server
|
|
complies. Format: CGI/revision</p><p>
|
|
|
|
</p></li></ul>
|
|
|
|
<hr>
|
|
|
|
The following environment variables are specific to the request being
|
|
fulfilled by the gateway program: <p>
|
|
|
|
</p><ul>
|
|
<li> <a name="protocol"><code>SERVER_PROTOCOL</code></a> <p>
|
|
The name and revision of the information protcol this request came
|
|
in with. Format: protocol/revision </p><p>
|
|
|
|
</p></li><li> <code>SERVER_PORT</code> <p>
|
|
The port number to which the request was sent. </p><p>
|
|
|
|
</p></li><li> <code>REQUEST_METHOD</code> <p>
|
|
The method with which the request was made. For HTTP, this is
|
|
"GET", "HEAD", "POST", etc. </p><p>
|
|
|
|
</p></li><li> <code>PATH_INFO</code> <p>
|
|
The extra path information, 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 should be
|
|
decoded by the server if it comes from a URL before it is passed
|
|
to the CGI script.</p><p>
|
|
|
|
</p></li><li> <code>PATH_TRANSLATED</code> <p>
|
|
The server provides a translated version of PATH_INFO, which takes
|
|
the path and does any virtual-to-physical mapping to it. </p><p>
|
|
|
|
</p></li><li> <code>SCRIPT_NAME</code> <p>
|
|
A virtual path to the script being executed, used for
|
|
self-referencing URLs. </p><p>
|
|
|
|
</p></li><li> <a name="query"><code>QUERY_STRING</code></a> <p>
|
|
The information which follows the ? in the <a href="http://www.ncsa.uiuc.edu/demoweb/url-primer.html">URL</a>
|
|
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 <a href="http://hoohoo.ncsa.uiuc.edu/cgi/cl.html">command line decoding</a>. </p><p>
|
|
|
|
</p></li><li> <code>REMOTE_HOST</code> <p>
|
|
The hostname making the request. If the server does not have this
|
|
information, it should set REMOTE_ADDR and leave this unset.</p><p>
|
|
|
|
</p></li><li> <code>REMOTE_ADDR</code> <p>
|
|
The IP address of the remote host making the request. </p><p>
|
|
|
|
</p></li><li> <code>AUTH_TYPE</code> <p>
|
|
If the server supports user authentication, and the script is
|
|
protects, this is the protocol-specific authentication method used
|
|
to validate the user. </p><p>
|
|
|
|
</p></li><li> <code>REMOTE_USER</code> <p>
|
|
If the server supports user authentication, and the script is
|
|
protected, this is the username they have authenticated as. </p><p>
|
|
</p></li><li> <code>REMOTE_IDENT</code> <p>
|
|
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.
|
|
</p><p>
|
|
|
|
</p></li><li> <a name="ct"><code>CONTENT_TYPE</code></a> <p>
|
|
For queries which have attached information, such as HTTP POST and
|
|
PUT, this is the content type of the data. </p><p>
|
|
|
|
</p></li><li> <a name="cl"><code>CONTENT_LENGTH</code></a> <p>
|
|
The length of the said content as given by the client. </p><p>
|
|
|
|
</p></li></ul>
|
|
|
|
|
|
<a name="headers"><hr></a>
|
|
|
|
In addition to these, the header lines received from the client, if
|
|
any, are placed into the environment with the prefix HTTP_ followed by
|
|
the header name. Any - characters in the header name are changed to _
|
|
characters. The server may exclude any headers which it has already
|
|
processed, such as Authorization, Content-type, and Content-length. If
|
|
necessary, the server may choose to exclude any or all of these
|
|
headers if including them would exceed any system environment
|
|
limits. <p>
|
|
|
|
An example of this is the HTTP_ACCEPT variable which was defined in
|
|
CGI/1.0. Another example is the header User-Agent.</p><p>
|
|
|
|
</p><ul>
|
|
<li> <code>HTTP_ACCEPT</code> <p>
|
|
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. </p><p>
|
|
|
|
Format: type/subtype, type/subtype </p><p>
|
|
|
|
|
|
</p></li><li> <code>HTTP_USER_AGENT</code><p>
|
|
|
|
The browser the client is using to send the request. General
|
|
format: <code>software/version library/version</code>.</p><p>
|
|
|
|
</p></li></ul>
|
|
|
|
<hr>
|
|
<h2>Examples</h2>
|
|
|
|
Examples of the setting of environment variables are really much better
|
|
<a href="http://hoohoo.ncsa.uiuc.edu/cgi/examples.html">demonstrated</a> than explained. <p>
|
|
|
|
</p><hr>
|
|
|
|
<a href="http://hoohoo.ncsa.uiuc.edu/cgi/interface.html"><img alt="[Back]" src="env_files/back.gif">Return to the
|
|
interface specification</a> <p>
|
|
|
|
CGI - Common Gateway Interface
|
|
</p><address><a href="http://hoohoo.ncsa.uiuc.edu/cgi/mailtocgi.html">cgi@ncsa.uiuc.edu</a></address>
|
|
|
|
</body></html> |