This specification provides no mechanism for an NPH script to be
identified on the basis of its output data alone. By convention,
therefore, any particular script can only ever provide output of one
type (NPH or CGI) and hence the script itself is described as an 'NPH
script'. A server with NPH support MUST provide an implementation-
defined mechanism for identifying NPH scripts, perhaps based on the
name or location of the script.
5.2. NPH Response
There MUST be a system-defined method for the script to send data
back to the server or client; a script MUST always return some data.
Unless defined otherwise, this will be the same as for conventional
CGI scripts.
Currently, NPH scripts are only defined for HTTP client requests. An
(HTTP) NPH script MUST return a complete HTTP response message,
currently described in section 6 of the HTTP specifications [1], [4].
The script MUST use the SERVER_PROTOCOL variable to determine the
appropriate format for a response. It MUST also take account of any
generic or protocol-specific meta-variables in the request as might
be mandated by the particular protocol specification.
The server MUST ensure that the script output is sent to the client
unmodified. Note that this requires the script to use the correct
character set (US-ASCII [9] and ISO 8859-1 [10] for HTTP) in the
header fields. The server SHOULD attempt to ensure that the script
output is sent directly to the client, with minimal internal and no
transport-visible buffering.
RFC 3875 CGI Version 1.1 October 2004
Unless the implementation defines otherwise, the script MUST NOT
indicate in its response that the client can send further requests
over the same connection.
6. CGI Response
6.1. Response Handling
A script MUST always provide a non-empty response, and so there is a
system-defined method for it to send this data back to the server.
Unless defined otherwise, this will be via the 'standard output' file
descriptor.
The script MUST check the REQUEST_METHOD variable when processing the
request and preparing its response.
The server MAY implement a timeout period within which data must be
received from the script. If a server implementation defines such a
timeout and receives no data from a script within the timeout period,
the server MAY terminate the script process.
6.2. Response Types
The response comprises a message-header and a message-body, separated
by a blank line. The message-header contains one or more header
fields. The body may be NULL.
generic-response = 1*header-field NL [ response-body ]
The script MUST return one of either a document response, a local
redirect response or a client redirect (with optional document)
response. In the response definitions below, the order of header
fields in a response is not significant (despite appearing so in the
BNF). The header fields are defined in section 6.3.
CGI-Response = document-response | local-redir-response |
client-redir-response | client-redirdoc-response
6.2.1. Document Response
The CGI script can return a document to the user in a document
response, with an optional error code indicating the success status
of the response.
document-response = Content-Type [ Status ] *other-field NL
response-body
RFC 3875 CGI Version 1.1 October 2004
The script MUST return a Content-Type header field. A Status header
field is optional, and status 200 'OK' is assumed if it is omitted.
The server MUST make any appropriate modifications to the script's
output to ensure that the response to the client complies with the
response protocol version.
=13= |