With a search, the response might be the URLs of all the documents that met the
search value. With a request that results in e-mail, the response might be a
message that confirms that the system actually sent the e-mail.
Environment variables
Before you begin writing your CGI program, you need to understand the format in
which the server will pass the data. The server receives the URL-encoded
information and, depending on the type of request, passes the information to the
CGI program. The server does this by using environment variables, command line
arguments, or standard input.
A CGI application program should be able to handle a NULL value when getting
an environment variable. For example, when the CGI program is trying to do a
getenv(CONTENT_LENGTH) and the method is GET, the value would be
returned NULL. This is because CONTENT_LENGTH is only defined in method
POST (to describe the length of standard input).
The system supports the following environment variables:
AUTH_TYPE
If the server supports client authentication and the script is a protected
script, this environment variable contains the method that is used to
authenticate the client. For example:
Basic
CGI_ASCII_CCSID
Contains the ASCII CCSID the server used when converting CGI input
data. If the server did not perform any conversion, (for example, in
%%BINARY%% mode), the server sets this value to the DefaultNetCCSID
configuration directive value.
CGI_MODE
Contains the CGI conversion mode the server is using for this request.
Valid values are %%EBCDIC%%, %%MIXED%%, %%BINARY%%,or
%%EBCDIC_JCD%%. The program can use this information to determine
what conversion, if any, was performed by the server on CGI input data
and what format that data is currently in.
CGI_EBCDIC_CCSID
Contains the EBCDIC CCSID under which the current server job is running
(DefaultFsCCSID configuration directive). It also represents the current job
CCSID that is used during server conversion (if any) of CGI input data.
CONTENT_LENGTH
When the method of POST is used to send information, this variable
contains the number of characters. Servers typically do not send an
end-of-file flag when they forward the information by using stdin. If
needed, you can use the CONTENT_LENGTH value to determine the end
of the input string. For example:
7034
CONTENT_TYPE
When information is sent with the method of POST, this variable contains
the type of data included. You can create your own content type in the
server configuration file and map it to a viewer. For example:
Application/x-www-form-urlencoded
Chapter1. Writing Common Gateway Interface Programs 13