Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.w3c.jigsaw.frames
Class CgiFrame

    java.lang.Object
      |
      +--org.w3c.tools.resources.AttributeHolder
            |
            +--org.w3c.tools.resources.Resource
                  |
                  +--org.w3c.tools.resources.FramedResource
                        |
                        +--org.w3c.tools.resources.ResourceFrame
                              |
                              +--org.w3c.tools.resources.ProtocolFrame
                                    |
                                    +--org.w3c.jigsaw.frames.HTTPFrame
                                          |
                                          +--org.w3c.jigsaw.frames.CgiFrame

public class CgiFrame
extends HTTPFrame

Handle CGI scripts.

Field Summary
`protected static int` | `ATTR_CGI_DEBUG` Attribute index - Turn the script in debug mode.
`protected static int` | `ATTR_COMMAND` Attribute index - The array of string that makes the command to run.
`protected static int` | `ATTR_ENV` Attribute index - Additional environment vars
`protected static int` | `ATTR_GENERATES_FORM` Attribute index - Does the script generates the form on GET ?
`protected static int` | `ATTR_INTERPRETER` Attribute index - The interpreter to use, if any.
`protected static int` | `ATTR_NOHEADER` Attribute index - Does the script takes care of its headers ?
`protected static int` | `ATTR_REMOTE_HOST` Attribute index - Do DNS, to fill in REMOTE_HOST env var.

Fields inherited from class org.w3c.jigsaw.frames.HTTPFrame
`acceptRanges, allowed, ATTR_ALLOW_DEL, ATTR_BROWSABLE, ATTR_CHARSET, ATTR_CONTENT_ENCODING, ATTR_CONTENT_LANGUAGE, ATTR_CONTENT_LENGTH, ATTR_CONTENT_TYPE, ATTR_ICON, ATTR_ICONDIR, ATTR_INDEX, ATTR_INDEXES, ATTR_MAXAGE, ATTR_MD5, ATTR_PUTABLE, ATTR_QUALITY, ATTR_RELOCATE, ATTR_STYLE_LINK, ATTR_TITLE, browsetype, COND_FAILED, COND_OK, COND_WEAK, dresource, fresource, listing, listing_stamp, STATE_CONTENT_LOCATION`

Fields inherited from class org.w3c.tools.resources.ResourceFrame
`filterClass, frameListener, resource`

Fields inherited from class org.w3c.tools.resources.FramedResource
`ATTR_OID, attrListener, debugEvent, event_disabled, framesRef, structListener`

Fields inherited from class org.w3c.tools.resources.Resource
`ATTR_CONTEXT, ATTR_HELP_URL, ATTR_IDENTIFIER, ATTR_LAST_MODIFIED, ATTR_PARENT, ATTR_RESOURCE_FRAMES, ATTR_STORE_ENTRY, ATTR_URL, co, id`

Fields inherited from class org.w3c.tools.resources.AttributeHolder
`attributes, values`

Constructor Summary
`CgiFrame()`

Method Summary
`boolean` | `checkCgiDebug()` Get the CGI debug flag.
`boolean` | `checkGeneratesFormFlag()` Get the generates form flag.
`boolean` | `checkNoheaderFlag()` Get the noheader flag.
`boolean` | `checkRemoteHost()` Get the remote host attribute value.
`Reply` | `get(Request request)` GET method implementation.
`java.lang.String[]` | `getCommand()` Get the command string array.
`java.lang.String` | `getEnvName(java.lang.String name)` Turn the given header name into it's env var canonical name.
`HttpEntityTag` | `getETag()` Get this resource Etag
`java.lang.String` | `getInterpreter()` Get the interpreter to use to execute the script.
`ArrayDictionary` | `getUserEnv()`
`protected Reply` | `handleCGIOutput(java.lang.Process process, Request request)` Handle the CGI script output.
`boolean` | `lookup(LookupState ls, LookupResult lr)` Lookup sub-resources.
`protected java.lang.Process` | `makeCgiCommand(Request request)` Prepare the command to run for this CGI script, and run it.
`Reply` | `post(Request request)` Handle the POST method according to CGI/1.1 specification.
`void` | `registerResource(FramedResource resource)` At register time, if no command, use a suitable default.

Methods inherited from class org.w3c.jigsaw.frames.HTTPFrame
`addStyleSheet, attributeChanged, browse, checkExpect, checkIfMatch, checkIfModifiedSince, checkIfNoneMatch, checkIfUnmodifiedSince, checkRequest, checkValidators, computeContainerListing, computeETag, computeTrashDir, computeTrashFile, createDefaultReply, createFileReply, delete, deleteDirectoryResource, deleteFileResource, deleteMe, deleteOtherResource, extended, getAllow, getAllowDeleteFlag, getBrowsableFlag, getBrowseType, getCharset, getContentEncoding, getContentLanguage, getContentLength, getContentType, getDirectoryListing, getDirectoryResource, getDirectoryResource, getFileResource, getFileResource, getHelpURL, getHelpURL, getIcon, getIconDirectory, getIndex, getIndexes, getMaxAge, getMD5Flag, getOtherResource, getPutableFlag, getQuality, getRelocateFlag, getStyleSheetURL, getTitle, getURL, handleRangeRequest, head, headDirectoryResource, headFileResource, headOtherResource, initialize, link, lookupDirectory, lookupFile, lookupOther, lookupResource, options, perform, performFrames, pickleValues, put, putFileResource, putOtherResource, registerOtherResource, setValue, trace, unlink, updateCachedHeaders`

Methods inherited from class org.w3c.tools.resources.ResourceFrame
`addFrameEventListener, eventDisabled, fireFrameEvent, frameModified, getFilters, getFilters, getFrameReference, getResource, getResourceReference, getSpaceEntry, getURLPath, lookupFilters, lookupFrames, postFrameEvent, processEvent, removeFrameEventListener, unregisterResource, updateDefaultChildAttributes`

Methods inherited from class org.w3c.tools.resources.FramedResource
`addAttributeChangedListener, addStructureChangedListener, collectFramesReference, delete, disableEvent, displayEvent, enableEvent, fireAttributeChangeEvent, fireStructureChangedEvent, fireStructureChangedEvent, frameAdded, frameRemoved, getClone, getFrame, getFrame, getFrameReference, getFrameReference, getFramesReference, getOid, initialize, markModified, notifyUnload, postAttributeChangeEvent, postEvent, postStructureChangedEvent, postStructureChangedEvent, registerFrame, registerFrameIfNone, removeAttributeChangedListener, removeStructureChangedListener, setSilentValue, setSilentValue, unregisterFrame`

Methods inherited from class org.w3c.tools.resources.Resource
`acceptUnload, checkMultipleLock, collectFrames, getContext, getFrame, getFrames, getIdentifier, getLastModified, getParent, getServer, getSpace, getStoreEntry, getValue, getValue, isInitialized, isUnloaded, setContext, setContext, setValue, unsafeGetContext, unsafeGetIdentifier, unsafeGetValue, updateAttributes`

Methods inherited from class org.w3c.tools.resources.AttributeHolder
`definesAttribute, definesAttribute, getAttributes, getBoolean, getChar, getClone, getClone, getDouble, getFloat, getInt, getLong, getString, getValue, lookupAttribute, print, setBoolean, setChar, setDouble, setFloat, setInt, setLong, setString, setValue, unsafeGetString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ATTR_INTERPRETER

    protected static int ATTR_INTERPRETER

  Attribute index - The interpreter to use, if any.

### ATTR_COMMAND

    protected static int ATTR_COMMAND

  Attribute index - The array of string that makes the command to run.

### ATTR_NOHEADER

    protected static int ATTR_NOHEADER

  Attribute index - Does the script takes care of its headers ?

### ATTR_GENERATES_FORM

    protected static int ATTR_GENERATES_FORM

  Attribute index - Does the script generates the form on GET ?

### ATTR_REMOTE_HOST

    protected static int ATTR_REMOTE_HOST

  Attribute index - Do DNS, to fill in REMOTE_HOST env var.

### ATTR_CGI_DEBUG

    protected static int ATTR_CGI_DEBUG

  Attribute index - Turn the script in debug mode.

### ATTR_ENV

    protected static int ATTR_ENV

  Attribute index - Additional environment vars

Constructor Detail

### CgiFrame

    public CgiFrame()

Method Detail

### getInterpreter

    public java.lang.String getInterpreter()

  Get the interpreter to use to execute the script. This is most usefull for operating systems that don't have a `!#` convention ala UNIX.
  Returns:
    The interpreter to run the script.

### getCommand

    public java.lang.String[] getCommand()

  Get the command string array.

### getUserEnv

    public ArrayDictionary getUserEnv()

### checkNoheaderFlag

    public boolean checkNoheaderFlag()

  Get the noheader flag.
  Returns:
    The boolean value of the noheader flag.

### checkGeneratesFormFlag

    public boolean checkGeneratesFormFlag()

  Get the generates form flag.
  Returns:
    The boolean value of the generates form flag.

### checkRemoteHost

    public boolean checkRemoteHost()

  Get the remote host attribute value. If turned on, this flag will enable the REMOTE_HOST env var computation.
  Returns:
    A boolean.

### checkCgiDebug

    public boolean checkCgiDebug()

  Get the CGI debug flag.
  Returns:
    The boolean value of the CGI debug flag.

### getEnvName

    public java.lang.String getEnvName(java.lang.String name)

  Turn the given header name into it's env var canonical name. This guy is crazy enough to run CGI scripts, he can pay for that overhead.
  Parameters:
    `name` - The header name.
  Returns:
    A String giving the official env variable name for that header.

### getETag

    public HttpEntityTag getETag()

  Get this resource Etag
  Overrides:
    getETag in class HTTPFrame
  Returns:
    an instance of HttpEntityTag, or null if not defined.

### handleCGIOutput

    protected Reply handleCGIOutput(java.lang.Process process,
                                    Request request)
                             throws ProtocolException

  Handle the CGI script output. This methods handles the CGI script output. Depending on the value of the noheader attribute it either:
  - Sends back the script output directly,
  - Parses the script output, looking for a status header or a location header, or a content-length header, or any combination of those three.
  Parameters:
    `process` - The underlying CGI process.
    `request` - The processed request.
  Throws:
    ProtocolException - If an HTTP error should be sent back to the client.

### makeCgiCommand

    protected java.lang.Process makeCgiCommand(Request request)
                                        throws ProtocolException,
                                               java.io.IOException

  Prepare the command to run for this CGI script, and run it.
  Parameters:
    `request` - The request to handle.
  Returns:
    The running CGI process object.
  Throws:
    ProtocolException - If we weren't able to build the command or the environment.
    java.io.IOException - if an IO erro occurs.

### lookup

    public boolean lookup(LookupState ls,
                          LookupResult lr)
                   throws ProtocolException

  Lookup sub-resources. Accumulate the remaning path in some special state of the request.

  This allows us to implement the `PATH_INFO` CGI variable properly.

  Overrides:
    lookup in class HTTPFrame
  Parameters:
    `ls` - Current lookup state.
    `lr` - Lookup result under construction.
  Returns:
    A boolean true if lookup should continue, false otherwise.
  Throws:
    ProtocolException - (fixme doc)

### get

    public Reply get(Request request)
              throws ProtocolException,
                     ResourceException

  GET method implementation. this method is splitted into two cases:

  If the resource is able to generates its form, than run the script to emit the form. Otherwsie, use our super class (FileResource) ability to send the file that contains the form.

  Note that there is no need to feed the underlying process with data in the GET case.

  Overrides:
    get in class HTTPFrame
  Parameters:
    `request` - The request to handle.
  Throws:
    ProtocolException - If processing the request failed.
    ResourceException - If the resource got a fatal error.

### post

    public Reply post(Request request)
               throws ProtocolException,
                      ResourceException

  Handle the POST method according to CGI/1.1 specification. The request body is sent back to the launched CGI script, as is, and the script output is handled by the handleCGIOutput method.
  Overrides:
    post in class HTTPFrame
  Parameters:
    `request` - The request to process.
  Throws:
    ProtocolException - If the processing failed.
    ResourceException - If the resource got a fatal error.

### registerResource

    public void registerResource(FramedResource resource)

  At register time, if no command, use a suitable default. THis method will set the command to the identifier, if it is not provided.
  Overrides:
    registerResource in class HTTPFrame
  Parameters:
    `values` - Default attribute values.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD