| java.lang.Object sunlabs.brazil.handler.CgiHandler
CgiHandler | public class CgiHandler implements Handler(Code) | | Handler for implementing cgi/1.1 interface.
This implementation allows either suffix matching (e.g. .cgi) to identify
cgi scripts, or prefix matching (e.g. /bgi-bin). Defaults to "/".
All output from the cgi script is buffered (e.g. chunked encoding is
not supported).
NOTE: this handler does not "cd" to the script directory before
running the script; The code to "cd" in Java is too messy to bother.
The following request properties are used:
- root
- The document root for cgi files
- suffix
- The suffix for cgi files (defaults to .cgi)
- prefix
- The prefix for all cgi files (e.g. /cgi-bin)
- custom
- set to "true" to enable custom environment variables.
If set, all server properties starting with this handler's
prefix are placed into the environment with the name:
CONFIG_name , where name is the
property key, in upper case, with the prefix removed.
This allows cgi scripts to be customized in the server's
configuration file.
author: Stephen Uhler version: 1.17, 00/12/11 |
Method Summary | |
public boolean | init(Server server, String prefix) One time initialization. | public boolean | respond(Request request) Dispatch and handle the CGI request. |
CgiHandler | public CgiHandler()(Code) | | |
init | public boolean init(Server server, String prefix)(Code) | | One time initialization. The handler configuration properties are
extracted and set in
CgiHandler.respond(Request) to allow
upstream handlers to modify the parameters.
|
respond | public boolean respond(Request request)(Code) | | Dispatch and handle the CGI request. Gets called on ALL requests.
Set up the environment, exec the process, and deal
appropriately with the input and output.
In this implementation, all cgi script files must end with a
standard suffix, although the suffix may omitted from the url.
The url /main/do/me/too?a=b will look, starting in DocRoot,
for main.cgi, main/do.cgi, etc until a matching file is found.
Input parameters examined in the request properties:
- Suffix
- The suffix for all cgi scripts (defaults to .cgi)
- DocRoot
- The document root, for locating the script.
|
|
|