Table2. Conversion action and charset tag generation for text in CGI Stdout. (continued)
CGI Stdout CCSID/Charset in HTTP header Conversion action Server reply charset tag
None (%%MIXED%% or
%%MIXED/MIXED%%)
Default Conversion - FsCCSID to
NetCCSID
None (compatibility mode)
Invalid CGI error 500 generated by server
The server also sets an environment variable CGI_OUTPUT_MODE to reflect the
setting for the CGI output mode. It contains the CGI output conversion mode the
server is using for this request. Valid values are %%EBCDIC%%, %%MIXED%%, or
%%BINARY%%. The program can use this information to determine what
conversion, if any, the server performs on CGI output.
Returning Output from the Server
When the CGI program is finished, it passes the resulting response to the server by
using standard output (stdout). The server interprets the response and sends it to
the browser.
A CGI program writes a CGI header that is followed by an entity body to standard
output. The CGI header is the information that describes the data in the entity
body. The entity body is the data that the server sends to the client.A single
newline character always ends the CGI header. The newline character for ILE/C is
\n. For ILE/RPG or ILE/COBOL, it is hexadecimal 15. The following are some
examples of Content-Type headers:
Content-Type: text/html\n\n
Content-Type: text/html; charset=iso-8859-2\n\n
If the response is a static document, the CGI program returns either the URL of the
document using the CGI Location header or returns a Status header. The CGI
program does not have an entity body when using the Location header. If the host
name is the local host, the HTTP server will retrieve the specified document that
the CGI program sent. It will then send a copy to the web browser. If the host
name is not the local host, the HTTP processes it as a redirect to the web browser.
For example:
Location: http://www.acme.com/products.html\n\n
The Status header should have a Content_Type: and a Status in the CGI header.
When Status is in the CGI header, an entity body should be sent with the data to
be returned by the server. The entity body data contains information that the CGI
program provides to a client for error processing. The Status line is the Status with
an HTTP 3 digit status code and a string of alphanumeric characters (A-Z, a-z, 0-9
and space). The HTTP status code must be a valid 3 digit number from the
HTTP/1.1 specification.
Note: The newline character \n ends the CGI header.
CONTENT-TYPE: text/html\n
Status: 600 Invalid data\n
\n
<html><head><title>Invalid data</title>
</head><body>
<h1>Invalid data typed</h1>
<br><pre>
The data entered must be valid numeric digits for id number
<br></pre>
</body></html>
Chapter1. Writing Common Gateway Interface Programs 11