in Section 6 of the HTTP specification [3]. Note that this allows an
HTTP/0.9 response to an HTTP/1.0 request.
The server should attempt to ensure that the script output is sent
directly to the client, with minimal buffering.
9.2. Parsed Header Output
The script returns a CGI response message.
CGI-Response = *( CGI-Header | HTTP-Header ) NL [ Entity-Body ]
CGI-Header = Content-type
| Location
| Status
| extension-header
The response comprises headers and a body, separated by a blank line.
The headers are either CGI headers to be interpreted by the server,
or HTTP headers to be included in the response returned to the client
if the request method is HTTP. At least one CGI-Header must be
supplied, but no CGI header can be repeated with the same field-name.
INTERNET-DRAFT Common Gateway Interface - 1.1 15 February 1996
If a body is supplied, then a Content-type header is required,
otherwise the script must send a Location or Status header. If a
Location header is returned, then no HTTP-Headers may be supplied.
The CGI headers have the generic syntax:
generic-header = field-name ":" [ field-value ] NL
field-name = 1*<any CHAR, excluding CTLs, SP and ":">
field-value = *( field-content | LWSP )
field-content = *( token | tspecial | quoted-string )
The field-name is not case sensitive; a NULL field value is
equivalent to the header not being sent.
Content-Type
The Internet Media Type [9] of the entity body, which is to be
sent unmodified to the client.
Content-Type = "Content-Type" ":" media-type NL
Location
This is used to specify to the server that the script is returning
a reference to a document rather than an actual document.
Location = "Location" ":"
( fragment-URI | rel-URL-abs-path ) NL
fragment-URI = URI [ # fragmentid ]
URI = scheme ":" *qchar
fragmentid = *qchar
rel-URL-abs-path = "/" [ hpath ] [ "?" query-string ]
hpath = fpsegment *( "/" psegment )
fpsegment = 1*hchar
psegment = *hchar
hchar = alpha | digit | safe | extra
| ":" | "@" | "& | "="
The location value is either an absolute URI with optional
fragment, as defined in RFC 1630 [1], or an absolute path and
optional query-string. If an absolute URI is returned by the
script, then the server will generate a redirect HTTP response
message, and if no entity body is supplied by the script, then the
server will produce one. If the Location value is a path, then the
server will generate the response that it would have produced in
response to a request containing the URL
protocol "://" SERVER_NAME ":" SERVER_PORT rel-URL-abs-path
INTERNET-DRAFT Common Gateway Interface - 1.1 15 February 1996
The location header may only be sent if the REQUEST_METHOD is HEAD
or GET.
Status
The Status header is used to indicate to the server what status
code it will use in the response message. It should not be sent if
the script returns a Location header.
Status = "Status" ":" 3digit SP reason-phrase NL
reason-phrase = *<CHAR, excluding CTLs, NL>
The valid status codes are listed in section 6.1.1 of the HTTP/1.0
specification [3]. If the script does not return a Status header,
then "200 OK" should be assumed.
=8= |