org.apache.catalina.util
Class ProcessHelper
java.lang.Object
org.apache.catalina.util.ProcessHelper
public class ProcessHelper
extends java.lang.Object
Encapsulates the knowledge of how to run a CGI script, given the
script's desired environment and (optionally) input/output streams
Exposes a
run
method used to actually invoke the
CGI.
The CGI environment and settings are derived from the information
passed to the constuctor.
The input and output streams can be set by the
setInput
and
setResponse
methods, respectively.
Version:
- Martin Dengler [root@martindengler.com]
ProcessHelper(String command, Hashtable env, File wd, Hashtable params) - Creates a ProcessHelper and initializes its environment, working
directory, and query parameters.
|
int | getIClientInputTimeout()
|
protected String | getPostInput(Hashtable params) - Gets a string for input to a POST cgi script
|
boolean | isReady() - Gets ready status
|
void | run() - Executes a process script with the desired environment, current working
directory, and input/output streams
This implements the following CGI specification recommedations:
- Servers SHOULD provide the "
query " component of
the script-URI as command-line arguments to scripts if it
does not contain any unencoded "=" characters and the
command-line arguments can be generated in an unambiguous
manner.
|
void | setIClientInputTimeout(int iClientInputTimeout)
|
void | setInput(InputStream stdin) - Sets standard input to be passed on to the invoked cgi script
|
void | setResponse(HttpServletResponse response) - Sets HttpServletResponse object used to set headers and send
output to
|
protected void | updateReadyStatus() - Checks & sets ready status
|
ProcessHelper
public ProcessHelper(String command,
Hashtable env,
File wd,
Hashtable params)
Creates a ProcessHelper and initializes its environment, working
directory, and query parameters.
Input/output streams (optional) are set using the
setInput
and setResponse
methods,
respectively.
command
- string full path to command to be executedenv
- Hashtable with the desired script environmentwd
- File with the script's desired working directoryparams
- Hashtable with the script's query parameters
getIClientInputTimeout
public int getIClientInputTimeout()
getPostInput
protected String getPostInput(Hashtable params)
Gets a string for input to a POST cgi script
params
- Hashtable of query parameters to be passed to
the CGI script
- for use as input to the CGI script
isReady
public boolean isReady()
Gets ready status
- false if not ready (
run
will throw
an exception), true if ready
run
public void run()
throws IOException
Executes a process script with the desired environment, current working
directory, and input/output streams
This implements the following CGI specification recommedations:
- Servers SHOULD provide the "
query
" component of
the script-URI as command-line arguments to scripts if it
does not contain any unencoded "=" characters and the
command-line arguments can be generated in an unambiguous
manner.
- Servers SHOULD set the AUTH_TYPE metavariable to the value
of the "
auth-scheme
" token of the
"Authorization
" if it was supplied as part of the
request header. See getCGIEnvironment
method.
- Where applicable, servers SHOULD set the current working
directory to the directory in which the script is located
before invoking it.
- Server implementations SHOULD define their behavior for the
following cases:
- Allowed characters in pathInfo: This implementation
does not allow ASCII NUL nor any character which cannot
be URL-encoded according to internet standards;
- Allowed characters in path segments: This
implementation does not allow non-terminal NULL
segments in the the path -- IOExceptions may be thrown;
- "
.
" and "..
" path
segments:
This implementation does not allow ".
" and
"..
" in the the path, and such characters
will result in an IOException being thrown;
- Implementation limitations: This implementation
does not impose any limitations except as documented
above. This implementation may be limited by the
servlet container used to house this implementation.
In particular, all the primary CGI variable values
are derived either directly or indirectly from the
container's implementation of the Servlet API methods.
For more information, see java.lang.Runtime#exec(String command,
String[] envp, File dir)
setIClientInputTimeout
public void setIClientInputTimeout(int iClientInputTimeout)
setInput
public void setInput(InputStream stdin)
Sets standard input to be passed on to the invoked cgi script
stdin
- InputStream to be used
setResponse
public void setResponse(HttpServletResponse response)
Sets HttpServletResponse object used to set headers and send
output to
response
- HttpServletResponse to be used
updateReadyStatus
protected void updateReadyStatus()
Checks & sets ready status
Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.