iTP Secure WebServer System Administrator's Guide (iTPWebSvr 5.1+)
Using Common Gateway Interface (CGI) Programs
iTP Secure WebServer System Administrator’s Guide—522659-001
8-27
Server Headers
A web client cannot properly interpret CGI program output unless it knows the output
data (MIME) type. Therefore, every response generated by a CGI program must contain
a Content-type: header. For example:
Content-type: text/html
Clients ignore any headers they are unable to interpret.
Server Headers
Two headers (Location: and Status:) are used by CGI programs to pass information
to the server rather than directly to the web client. These headers cause the server to
modify its response to the web client.
The
Location: header instructs the server to redirect the web client to another URL.
This redirection consists of a specific URL the web client should access in place of the
original URL. For example, a CGI program returning the header
Location: http://www.foo.com/home.html
is instructing the server to redirect the web client to a URL
http://www.foo.com/home.html
The Status: header instructs the server to return a specific status response to the web
client. This status information consists of a numeric HTTP status code followed by text
explaining the code. For example, a CGI program might cause the server to return a bad-
request response to the web client:
Status: 400 Bad Request
Content-type: text/html
<HTML><HEAD>
<TITLE>Bad Request</TITLE>
</HEAD><BODY>
You sent this server a bad request.
</BODY></HTML>
For a complete list of the HTTP status codes, see Table C-2, HTTP Status Codes, on
page C-3.
Nonparsed Headers
CGI programs can use the nonparsed header feature to return responses directly to the
web client.
To use this feature, the CGI program must have a file name that begins with nph- (for
example, nph-payment.cgi). This marker tells the server not to process any of the CGI
program’s output.
A CGI program using the nonparsed feature must construct a complete HTTP response,
including all status and header information.