    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class org.w3c.jigsaw.frames.HTTPFrame

    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

public class HTTPFrame
extends ProtocolFrame

Default class to handle the HTTP protocol, manage FileResource and DirectoryResource.

##

_allowed
acceptRanges
  Does this resource support byte ranges.
allowed
ATTR_BROWSABLE
  Attribute index - Allow the GNN browse method.
ATTR_CONTENT_ENCODING
  Attribute index - The index for the content encodings attribute.
ATTR_CONTENT_LANGUAGE
  Attribute index - The index for the content languages attribute.
ATTR_CONTENT_LENGTH
  Attribute index - The index for the content length attribute.
ATTR_CONTENT_TYPE
  Attribute index - The index for the content type attribute.
ATTR_ICON
  Attribute index - The icon (if any) associated to the resource.
ATTR_ICONDIR
  Attribute index - The icon directory to use in dir listing.
ATTR_INDEX
  Attribute index - our index resource name.
ATTR_MAXAGE
  Attribute index - Max age: the maximum drift allowed from reality.
ATTR_MD5
  Attribute index - Send MD5 Digest: the md5 digest of the resource sent
ATTR_PUTABLE
  Attribute index - Do we allow PUT method on this file.
ATTR_QUALITY
  Attributes index - The index for the quality attribute.
ATTR_RELOCATE
  Attribute index - The index for our relocate attribute.
ATTR_STYLE_LINK
  Attribute index - Style sheet for directory listing
ATTR_TITLE
  Attribute index - The index for the title attribute.
browsetype
  Handle the browse method.
COND_FAILED
  Condition check return code - Condition existed but failed.
COND_OK
  Condition check return code - Condition existed and succeeded.
dresource
filterClass
  The special class of filter.
fresource
listing
  Our current (cached) directory listing.
listing_stamp
  The time at which we generated the directory index.

##

HTTPFrame()

##

addStyleSheet(HtmlGenerator)
  Add our own Style Sheet to the HtmlGenerator.
attributeChanged(AttributeChangedEvent)
  Listen its resource.
browse(Request)
  A present to GNNPress users ! This method implements the `BROWSE` method that AOL press (or GNN press, or whatever its last name is) expects.
checkIfMatch(Request)
  Check the `If-Match` condition of that request.
checkIfModifiedSince(Request)
  Check the `If-Modified-Since` condition of that request.
checkIfNoneMatch(Request)
  Check the `If-None-Match` condition of that request.
checkIfUnmodifiedSince(Request)
  Check the `If-Unmodified-Since` condition of that request.
checkRequest(RequestInterface)
  Check if this kind of request can be perform by this resource.
createDefaultReply(Request, int)
  Create a reply to answer to request on this file.
createFileReply(Request)
  Create the reply relative to the given file.
delete(Request)
  The default DELETE method replies with a not implemented.
extended(Request)
  The handler for unknown method replies with a not implemented.
get(Request)
  The default GET method.
getBrowsableFlag()
  Get this class browsable flag.
getBrowseType()
getContentEncoding()
  Get this resource content encoding.
getContentLanguage()
  Get this resource content language.
getContentLength()
  Get this resource content length.
getContentType()
  Get this resource content type.
getDirectoryListing(Request)
  Reply with an HTML doc listing the resources of this directory.
getDirectoryResource()
getDirectoryResource(Request)
getFileResource()
getFileResource(Request)
getFilters()
  Get our whole list of filters.
getFilters(Class)
  Get the list of filters of this class.
getHelpURL()
  Get this resource's help url.
getHelpURL(String)
  Get the help URL for that resource's attribute.
getIcon()
  Get this resource's icon.
getIconDirectory()
  Get the optional icon directory.
getIndex()
  Get the optinal index name for this directory listing.
getMaxAge()
  Get this resource's max age.
getMD5Flag()
  Do we send the MD5 digest?
getOtherResource(Request)
getPutableFlag()
  Get the PUT'able flag (are we allow to PUT to the resource ?)
getQuality()
  Get this resource quality.
getRelocateFlag()
  Should we relocate invalid requests to this directory.
getStyleSheetURL()
  Get this frame style sheet link
getTitle()
  Get this resource title.
getURL(Request)
  Get the full URL for that resource.
handleRangeRequest(Request, HttpRange)
  handles a Range Request
head(Request)
  The default HEAD method replies does a GET and removes entity.
headDirectoryResource(Request)
headFileResource(Request)
headOtherResource(Request)
link(Request)
  The default LINK method replies with a not implemented.
lookup(LookupState, LookupResult)
  FIXME doc
lookupDirectory(LookupState, LookupResult)
lookupFile(LookupState, LookupResult)
lookupFilters(LookupState, LookupResult)
lookupOther(LookupState, LookupResult)
lookupResource(LookupState, LookupResult)
options(Request)
  The default OPTIONS method replies with a not implemented.
perform(RequestInterface)
  FIXME doc
performFrames(RequestInterface)
  Perform the request on all the frames of that resource.
post(Request)
  The default POST method replies with a not implemented.
put(Request)
  The default PUT method replies with a not implemented.
putFileResource(Request)
putOtherResource(Request)
registerOtherResource(FramedResource)
  use this one instead of registerResource if the resource type doesn't matter or if this is not a file or a directory resource.
registerResource(FramedResource)
  Register a target resource.
setValue(int, Object)
  Catch setValue, to maintain cached header values correctness.
trace(Request)
  The default TRACE method replies with a not implemented
unlink(Request)
  The default UNLINK method replies with a not implemented.
updateCachedHeaders()
  Update the cached headers value.

##

filterClass

     protected static Class filterClass

  The special class of filter.

COND_FAILED

     public static final int COND_FAILED

  Condition check return code - Condition existed but failed.

COND_OK

     public static final int COND_OK

  Condition check return code - Condition existed and succeeded.

_allowed

     protected static HttpTokenList _allowed

allowed

     protected HttpTokenList allowed

ATTR_QUALITY

     protected static int ATTR_QUALITY

  Attributes index - The index for the quality attribute.

ATTR_TITLE

     protected static int ATTR_TITLE

  Attribute index - The index for the title attribute.

ATTR_CONTENT_LANGUAGE

     protected static int ATTR_CONTENT_LANGUAGE

  Attribute index - The index for the content languages attribute.

ATTR_CONTENT_ENCODING

     protected static int ATTR_CONTENT_ENCODING

  Attribute index - The index for the content encodings attribute.

ATTR_CONTENT_TYPE

     protected static int ATTR_CONTENT_TYPE

  Attribute index - The index for the content type attribute.

ATTR_CONTENT_LENGTH

     protected static int ATTR_CONTENT_LENGTH

  Attribute index - The index for the content length attribute.

ATTR_ICON

     protected static int ATTR_ICON

  Attribute index - The icon (if any) associated to the resource.

ATTR_MAXAGE

     protected static int ATTR_MAXAGE

  Attribute index - Max age: the maximum drift allowed from reality.

ATTR_MD5

     protected static int ATTR_MD5

  Attribute index - Send MD5 Digest: the md5 digest of the resource sent

ATTR_PUTABLE

     protected static int ATTR_PUTABLE

  Attribute index - Do we allow PUT method on this file.

ATTR_RELOCATE

     protected static int ATTR_RELOCATE

  Attribute index - The index for our relocate attribute.

ATTR_INDEX

     protected static int ATTR_INDEX

  Attribute index - our index resource name.

ATTR_ICONDIR

     protected static int ATTR_ICONDIR

  Attribute index - The icon directory to use in dir listing.

ATTR_BROWSABLE

     protected static int ATTR_BROWSABLE

  Attribute index - Allow the GNN browse method.

ATTR_STYLE_LINK

     protected static int ATTR_STYLE_LINK

  Attribute index - Style sheet for directory listing

dresource

     protected DirectoryResource dresource

fresource

     protected FileResource fresource

acceptRanges

     protected boolean acceptRanges

  Does this resource support byte ranges.

listing

     protected HtmlGenerator listing

  Our current (cached) directory listing.

listing_stamp

     protected long listing_stamp

  The time at which we generated the directory index.

browsetype

     protected static MimeType browsetype

  Handle the browse method.

##

HTTPFrame

     public HTTPFrame()

##

registerResource

     public void registerResource(FramedResource resource)

  Register a target resource.

  Overrides:
    registerResource in class ResourceFrame

getFileResource

     public FileResource getFileResource()

getDirectoryResource

     public DirectoryResource getDirectoryResource()

registerOtherResource

     public void registerOtherResource(FramedResource resource)

  use this one instead of registerResource if the resource type doesn't matter or if this is not a file or a directory resource. In subclasses you should have to do that:

        public void registerResource(FramedResource resource) {
         super.registerOtherResource(resource);
        }

  Parameters:
    the - resource to register.

getHelpURL

     public String getHelpURL()

  Get this resource's help url.

  Returns:
    An URL, encoded as a String, or null if not available.
  Overrides:
    getHelpURL in class Resource

getHelpURL

     public String getHelpURL(String topic)

  Get the help URL for that resource's attribute.

  Parameters:
    topic - The topic (can be an attribute name, or a property, etc).
  Returns:
    A String encoded URL, or null.
  Overrides:
    getHelpURL in class Resource

attributeChanged

     public void attributeChanged(AttributeChangedEvent evt)

  Listen its resource.

  Overrides:
    attributeChanged in class ResourceFrame

setValue

     public synchronized void setValue(int idx,
                                       Object value)

  Catch setValue, to maintain cached header values correctness.

  Parameters:
    idx - The index of the attribute to be set.
    value - The new value for the attribute.
  Overrides:
    setValue in class ResourceFrame

getURL

     public URL getURL(Request request)

  Get the full URL for that resource.

  Returns:
    An URL instance.

getQuality

     public double getQuality()

  Get this resource quality.

  Returns:
    The resource quality, or some negative value if not defined.

getTitle

     public String getTitle()

  Get this resource title.

  Returns:
    This resource's title, or null if not defined.

getContentLanguage

     public String getContentLanguage()

  Get this resource content language. Language are stored as a comma separated String of tokens.

  Returns:
    A comma separated string of language tokens, or null if undefined.

getContentEncoding

     public String getContentEncoding()

  Get this resource content encoding. The content encoding of a resource is stored as a comma separated list of tokens (as decribed in the Content_encoding header of the HTTP specification, and in the order they should appear in the header).

  Returns:
    A string of comma separated encoding tokens, or null if not defined.

getContentType

     public MimeType getContentType()

  Get this resource content type.

  Returns:
    An instance of MIMEType, or null if not defined.

getContentLength

     public int getContentLength()

  Get this resource content length.

  Returns:
    The resource content length, or -1 if not defined.

getIcon

     public String getIcon()

  Get this resource's icon.

getMaxAge

     public long getMaxAge()

  Get this resource's max age. The max age of a resource indicates how much drift is allowed between the physicall version of the resource, and any in-memory cached version of it.

  The max age attribute is a long number giving the number of milliseconds of allowed drift.

getPutableFlag

     public boolean getPutableFlag()

  Get the PUT'able flag (are we allow to PUT to the resource ?)

getMD5Flag

     public boolean getMD5Flag()

  Do we send the MD5 digest?

handleRangeRequest

     public Reply handleRangeRequest(Request request,
                                     HttpRange r) throws ProtocolException

  handles a Range Request

  Parameters:
    request, - the request
    r, - the HttpRange
  Returns:
    a Reply if range is valid, or null if there is a change in the resource, or if the HttpRange is not valid ( 4-2, for example).

getBrowsableFlag

     public boolean getBrowsableFlag()

  Get this class browsable flag.

getStyleSheetURL

     public String getStyleSheetURL()

  Get this frame style sheet link

getIconDirectory

     public String getIconDirectory()

  Get the optional icon directory.

getRelocateFlag

     public boolean getRelocateFlag()

  Should we relocate invalid requests to this directory.

  Returns:
    A boolean true if we should relocate.

getIndex

     public String getIndex()

  Get the optinal index name for this directory listing.

  Returns:
    The name of the resource responsible to list that container.

addStyleSheet

     protected void addStyleSheet(HtmlGenerator g)

  Add our own Style Sheet to the HtmlGenerator.

  Parameters:
    g - The HtmlGenerator.

getDirectoryListing

     public synchronized Reply getDirectoryListing(Request request) throws ProtocolException, NotAProtocolException

  Reply with an HTML doc listing the resources of this directory. This function takes special care not to regenerate a directory listing when one is available. It also caches the date of the directory listing, so that it can win big with NOT_MODIFIED.

  Using a modem, I know that each place I can reply with an NOT_MODIFIED, is a big win.

  Parameters:
    request - The request to handle.
  Throws: ProtocolException
    If processsing the request failed.

updateCachedHeaders

     protected void updateCachedHeaders()

  Update the cached headers value. Each resource maintains a set of cached values for headers, this allows for a nice sped-up in headers marshalling, which - as the complexity of the protocol increases - becomes a bottleneck.

createDefaultReply

     public Reply createDefaultReply(Request request,
                                     int status)

  Create a reply to answer to request on this file. This method will create a suitable reply (matching the given request) and will set all its default header values to the appropriate values.

  Parameters:
    request - The request to make a reply for.
  Returns:
    An instance of Reply, suited to answer this request.

checkIfMatch

     public int checkIfMatch(Request request)

  Check the `If-Match` condition of that request.

  Parameters:
    request - The request to check.
  Returns:
    An integer, either `COND_FAILED if condition was checked, but failed, `COND_OK` if condition was checked and succeeded, or 0 if the condition was not checked at all (eg because the resource or the request didn't support it).`

checkIfNoneMatch

     public int checkIfNoneMatch(Request request)

  Check the `If-None-Match` condition of that request.

  Parameters:
    request - The request to check.
  Returns:
    An integer, either `COND_FAILED if condition was checked, but failed, `COND_OK` if condition was checked and succeeded, or 0 if the condition was not checked at all (eg because the resource or the request didn't support it).`

checkIfModifiedSince

     public int checkIfModifiedSince(Request request)

  Check the `If-Modified-Since` condition of that request.

  Parameters:
    request - The request to check.
  Returns:
    An integer, either `COND_FAILED if condition was checked, but failed, `COND_OK` if condition was checked and succeeded, or 0 if the condition was not checked at all (eg because the resource or the request didn't support it).`

checkIfUnmodifiedSince

     public int checkIfUnmodifiedSince(Request request)

  Check the `If-Unmodified-Since` condition of that request.

  Parameters:
    request - The request to check.
  Returns:
    An integer, either `COND_FAILED if condition was checked, but failed, `COND_OK` if condition was checked and succeeded, or 0 if the condition was not checked at all (eg because the resource or the request didn't support it).`

lookup

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

  FIXME doc

  Overrides:
    lookup in class ResourceFrame

lookupResource

     protected boolean lookupResource(LookupState ls,
                                      LookupResult lr) throws ProtocolException

lookupFilters

     protected boolean lookupFilters(LookupState ls,
                                     LookupResult lr) throws ProtocolException

lookupDirectory

     protected boolean lookupDirectory(LookupState ls,
                                       LookupResult lr) throws ProtocolException

lookupFile

     protected boolean lookupFile(LookupState ls,
                                  LookupResult lr) throws ProtocolException

lookupOther

     protected boolean lookupOther(LookupState ls,
                                   LookupResult lr) throws ProtocolException

checkRequest

     public boolean checkRequest(RequestInterface request)

  Check if this kind of request can be perform by this resource.

  Overrides:
    checkRequest in class ResourceFrame

performFrames

     protected ReplyInterface performFrames(RequestInterface request) throws ProtocolException, NotAProtocolException

  Perform the request on all the frames of that resource.

  Overrides:
    performFrames in class FramedResource

perform

     public ReplyInterface perform(RequestInterface req) throws ProtocolException, NotAProtocolException

  FIXME doc

  Overrides:
    perform in class ResourceFrame

get

     public Reply get(Request request) throws ProtocolException, NotAProtocolException

  The default GET method.

  Parameters:
    request - The request to handle.
  Throws: ProtocolException
    if processing the request failed.
  Throws: NotAProtocolException
    If the client instance controling the request processing got a fatal error.

getOtherResource

     protected Reply getOtherResource(Request request) throws ProtocolException, NotAProtocolException

createFileReply

     protected Reply createFileReply(Request request) throws ProtocolException, NotAProtocolException

  Create the reply relative to the given file.

  Parameters:
    request - the incomming request.
  Returns:
    A Reply instance

getFileResource

     protected Reply getFileResource(Request request) throws ProtocolException, NotAProtocolException

getDirectoryResource

     protected Reply getDirectoryResource(Request request) throws ProtocolException, NotAProtocolException

head

     public Reply head(Request request) throws ProtocolException, NotAProtocolException

  The default HEAD method replies does a GET and removes entity.

  Parameters:
    request - The request to handle.
  Throws: ProtocolException
    Always thrown, to return a NOT_IMPLEMENTED error.
  Throws: NotAProtocolException
    If the client instance controling the request processing got a fatal error.

headOtherResource

     protected Reply headOtherResource(Request request) throws ProtocolException, NotAProtocolException

headDirectoryResource

     protected Reply headDirectoryResource(Request request) throws ProtocolException, NotAProtocolException

headFileResource

     protected Reply headFileResource(Request request) throws ProtocolException, NotAProtocolException

post

     public Reply post(Request request) throws ProtocolException, NotAProtocolException

  The default POST method replies with a not implemented.

  Parameters:
    request - The request to handle.
  Throws: ProtocolException
    Always thrown, to return a NOT_IMPLEMENTED error.
  Throws: NotAProtocolException
    If the client instance controling the request processing got a fatal error.

put

     public Reply put(Request request) throws ProtocolException, NotAProtocolException

  The default PUT method replies with a not implemented.

  Parameters:
    request - The request to handle.
  Throws: ProtocolException
    Always thrown, to return a NOT_IMPLEMENTED error.
  Throws: NotAProtocolException
    If the client instance controling the request processing got a fatal error.

putOtherResource

     protected Reply putOtherResource(Request request) throws ProtocolException

putFileResource

     protected Reply putFileResource(Request request) throws ProtocolException, NotAProtocolException

options

     public Reply options(Request request) throws ProtocolException, NotAProtocolException

  The default OPTIONS method replies with a not implemented.

  Parameters:
    request - The request to handle.
  Throws: ProtocolException
    In case of errors.
  Throws: NotAProtocolException
    If the client instance controling the request processing got a fatal error.

delete

     public Reply delete(Request request) throws ProtocolException, NotAProtocolException

  The default DELETE method replies with a not implemented.

  Parameters:
    request - The request to handle.
  Throws: ProtocolException
    Always thrown, to return a NOT_IMPLEMENTED error.
  Throws: NotAProtocolException
    If the client instance controling the request processing got a fatal error.

link

     public Reply link(Request request) throws ProtocolException, NotAProtocolException

  The default LINK method replies with a not implemented.

  Parameters:
    request - The request to handle.
  Throws: ProtocolException
    Always thrown, to return a NOT_IMPLEMENTED error.
  Throws: NotAProtocolException
    If the client instance controling the request processing got a fatal error.

unlink

     public Reply unlink(Request request) throws ProtocolException, NotAProtocolException

  The default UNLINK method replies with a not implemented.

  Parameters:
    request - The request to handle.
  Throws: ProtocolException
    Always thrown, to return a NOT_IMPLEMENTED error.
  Throws: NotAProtocolException
    If the client instance controling the request processing got a fatal error.

trace

     public Reply trace(Request request) throws HTTPException, ClientException

  The default TRACE method replies with a not implemented

  Parameters:
    request - The request to handle.
  Throws: HTTPException
    In case of errors.
  Throws: ClientException
    If the client instance controling the request processing got a fatal error.

extended

     public Reply extended(Request request) throws ProtocolException, NotAProtocolException

  The handler for unknown method replies with a not implemented.

  Parameters:
    request - The request to handle.
  Throws: ProtocolException
    Always thrown, to return a NOT_IMPLEMENTED error.
  Throws: NotAProtocolException
    If the client instance controling the request processing got a fatal error.

getBrowseType

     protected synchronized MimeType getBrowseType()

browse

     public Reply browse(Request request) throws ProtocolException

  A present to GNNPress users ! This method implements the `BROWSE` method that AOL press (or GNN press, or whatever its last name is) expects.

  Parameters:
    request - The request to process.
  Returns:
    A Reply instance.
  Throws: ProtocolException
    If some error occurs.

getFilters

     public synchronized ResourceFilter[] getFilters()

  Get our whole list of filters.

getFilters

     public synchronized ResourceFilter[] getFilters(Class cls)

  Get the list of filters of this class.

  Parameters:
    cls - The class of filters requested.
  Returns:
    An array of filters, which are instances of the given class.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index