Rex Swain's
CGI Environment Variable Demo

Last updated 20 March 1997

Server: cgi-int.tripod.com
Perl: version 5.008008

GET Demo    POST Demo    Source Code

VariableValue
Description
AUTH_TYPE[undefined]
Protocol-specific authentication method used to validate the user.
CONTENT_LENGTH[undefined]
Length of the data passed to the CGI program through STDIN; implies REQUEST_METHOD is "POST".
CONTENT_TYPE[undefined]
For queries which have attached information, such as HTTP POST and PUT, this is the MIME content type of the data.
DOCUMENT_ROOT[undefined]
The directory from which web documents are served.
GATEWAY_INTERFACECGI/1.1
CGI specification revision number to which server complies.
HTTP_ACCEPT*/*
List of the MIME types that the client can accept.
HTTP_CONNECTIONclose
[unanticipated]
HTTP_COOKIE[undefined]
Cookie values. [See Cookie Demo.]
HTTP_FROM[undefined]
The Email address of the user making the request. [Most browsers do not support this variable.]
HTTP_HOSTcgi-int.tripod.com
[unanticipated]
HTTP_REFERERhttps://ruevs2.tripod.com/cgi-bin/
environment.cgi?foo=1&bar=2
The URL of the document that the client pointed to before accessing the CGI program.
HTTP_USER_AGENTclaudebot
The browser the client is using.
PATH_INFO[undefined]
Extra path information, as given by the client.
PATH_TRANSLATED[undefined]
Server-provided version of PATH_INFO (with virtual-to-physical mapping).
QUERY_STRINGfoo=1&bar=2
Query information passed to the program following URL and "?"; implies REQUEST_METHOD is "GET".
REMOTE_ADDR10.126.24.9
IP address of remote host making the request.
REMOTE_HOST[undefined]
Remote hostname making the request.
REMOTE_IDENT[undefined]
If the HTTP server supports RFC 931 identification, then this variable will be set to the remote username retrieved from the server. Usage of this variable should be limited to logging only.
REMOTE_USER[undefined]
Authenticated username (see AUTH_TYPE).
REQUEST_METHODGET
The method with which the request was made (e.g., "GET" or "POST" or "HEAD").
REQUEST_URI/ruevs2/cgi-bin/
environment.cgi?foo=1&bar=2
[unanticipated]
SCRIPT_NAME/environment.cgi
Virtual path to the script being executed (used for self-referencing URLs).
SERVER_ADMINops@tripod.com
[unanticipated]
SERVER_NAMEcgi-int.tripod.com
Server host name, DNS alias, or IP address (as it would appear in self-referencing URLs).
SERVER_PORT80
Port number the request was sent to (i.e., the host on which the server is running).
SERVER_PROTOCOLHTTP/1.1
Name and revision of the information protocol this request came in with.
SERVER_SOFTWARE[undefined]
Name and version of the server software answering the request.

GET

One way to invoke a Perl program is with an HTML <A HREF=...>...</A> link. Parameters are passed to Perl after the URL and a ?. Try it...

Hit me: /cgi-bin/environment.cgi?foo=1&bar=2

When this page reappears, you should see REQUEST_METHOD of "GET". The parameter names and values arrive via QUERY_STRING, and should be "foo=1&bar=2".

POST

Another way to invoke a Perl program is with an HTML <FORM METHOD=post> tag, one or more <INPUT> tags, and an <INPUT TYPE=submit> tag. Try it...

foo: bar: Hit me:

When this page reappears, you should see REQUEST_METHOD of "POST". The parameter names and values arrive via STDIN, and would be something like "foo=1&bar=2". CONTENT_LENGTH will be set to the length of that string. CONTENT_TYPE will be something like "application/x-www-form-urlencoded".


See Also


Other Summaries and Demos


You are visitor [Odometer] since 18 August 1996


Copyright © 1996-1997 Rex Swain
Email rex@rexswain.com, Web http://www.rexswain.com/
Permission granted to distribute unmodified copies
Reports of errors or omissions appreciated