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.


Variable Index

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

Constructor Index

 o HTTPFrame()

Method Index

 o addStyleSheet(HtmlGenerator)
Add our own Style Sheet to the HtmlGenerator.
 o attributeChanged(AttributeChangedEvent)
Listen its resource.
 o 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.
 o checkIfMatch(Request)
Check the If-Match condition of that request.
 o checkIfModifiedSince(Request)
Check the If-Modified-Since condition of that request.
 o checkIfNoneMatch(Request)
Check the If-None-Match condition of that request.
 o checkIfUnmodifiedSince(Request)
Check the If-Unmodified-Since condition of that request.
 o checkRequest(RequestInterface)
Check the request.
 o createDefaultReply(Request, int)
Create a reply to answer to request on this file.
 o createFileReply(Request)
Create the reply relative to the given file.
 o delete(Request)
The default DELETE method replies with a not implemented.
 o extended(Request)
The handler for unknown method replies with a not implemented.
 o get(Request)
The default GET method.
 o getBrowsableFlag()
Get this class browsable flag.
 o getBrowseType()
Get the Browse Mime type.
 o getContentEncoding()
Get this resource content encoding.
 o getContentLanguage()
Get this resource content language.
 o getContentLength()
Get this resource content length.
 o getContentType()
Get this resource content type.
 o getDirectoryListing(Request)
Reply with an HTML doc listing the resources of this directory.
 o getDirectoryResource()
Get the associated DirectoryResource (if any)
 o getDirectoryResource(Request)
Perform a GET for the associated DirectoryResource.
 o getFileResource()
Get the associated FileResource (if any)
 o getFileResource(Request)
Get for FileResource
 o getHelpURL()
Get this resource's help url.
 o getHelpURL(String)
Get the help URL for that resource's attribute.
 o getIcon()
Get this resource's icon.
 o getIconDirectory()
Get the optional icon directory.
 o getIndex()
Get the optinal index name for this directory listing.
 o getMaxAge()
Get this resource's max age.
 o getMD5Flag()
Do we send the MD5 digest?
 o getOtherResource(Request)
The default GET method for other king of associated resource
 o getPutableFlag()
Get the PUT'able flag (are we allow to PUT to the resource ?)
 o getQuality()
Get this resource quality.
 o getRelocateFlag()
Should we relocate invalid requests to this directory.
 o getStyleSheetURL()
Get this frame style sheet link
 o getTitle()
Get this resource title.
 o getURL(Request)
Get the full URL for that resource.
 o handleRangeRequest(Request, HttpRange)
handles a Range Request
 o head(Request)
The default HEAD method replies does a GET and removes entity.
 o headDirectoryResource(Request)
Perform a HEAD request for the associated DirectoryResource.
 o headFileResource(Request)
Perform a HEAD request for the associated FileResource.
 o headOtherResource(Request)
Perform a HEAD request for the associated resource.
 o link(Request)
The default LINK method replies with a not implemented.
 o lookup(LookupState, LookupResult)
Lookup the target resource.
 o lookupDirectory(LookupState, LookupResult)
Lookup the target resource when associated with a DirectoryResource.
 o lookupFile(LookupState, LookupResult)
Lookup the target resource when associated with a FileResource.
 o lookupOther(LookupState, LookupResult)
Lookup the target resource when associated with an unknown resource.
 o lookupResource(LookupState, LookupResult)
Lookup the target resource (dispath to more specific lookup methods).
 o options(Request)
The default OPTIONS method replies with a not implemented.
 o perform(RequestInterface)
Perform the request
 o performFrames(RequestInterface)
Perform the request on all the frames of that resource.
 o post(Request)
The default POST method replies with a not implemented.
 o put(Request)
The default PUT method replies with a not implemented.
 o putFileResource(Request)
Change the content of the associated FileResource.
 o putOtherResource(Request)
Always throw a ProtocolException.
 o 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.
 o registerResource(FramedResource)
Register this frame to the given resource.
 o setValue(int, Object)
Catch setValue, to maintain cached header values correctness.
 o trace(Request)
The default TRACE method replies with a not implemented
 o unlink(Request)
The default UNLINK method replies with a not implemented.
 o updateCachedHeaders()
Update the cached headers value.

Variables

 o COND_FAILED
 public static final int COND_FAILED
Condition check return code - Condition existed but failed.

 o COND_OK
 public static final int COND_OK
Condition check return code - Condition existed and succeeded.

 o _allowed
 protected static HttpTokenList _allowed
Methods allowed by that class in general:

 o allowed
 protected HttpTokenList allowed
Methods allowed by instances of that class in particular:

 o ATTR_QUALITY
 protected static int ATTR_QUALITY
Attributes index - The index for the quality attribute.

 o ATTR_TITLE
 protected static int ATTR_TITLE
Attribute index - The index for the title attribute.

 o ATTR_CONTENT_LANGUAGE
 protected static int ATTR_CONTENT_LANGUAGE
Attribute index - The index for the content languages attribute.

 o ATTR_CONTENT_ENCODING
 protected static int ATTR_CONTENT_ENCODING
Attribute index - The index for the content encodings attribute.

 o ATTR_CONTENT_TYPE
 protected static int ATTR_CONTENT_TYPE
Attribute index - The index for the content type attribute.

 o ATTR_CONTENT_LENGTH
 protected static int ATTR_CONTENT_LENGTH
Attribute index - The index for the content length attribute.

 o ATTR_ICON
 protected static int ATTR_ICON
Attribute index - The icon (if any) associated to the resource.

 o ATTR_MAXAGE
 protected static int ATTR_MAXAGE
Attribute index - Max age: the maximum drift allowed from reality.

 o ATTR_MD5
 protected static int ATTR_MD5
Attribute index - Send MD5 Digest: the md5 digest of the resource sent

 o ATTR_PUTABLE
 protected static int ATTR_PUTABLE
Attribute index - Do we allow PUT method on this file.

 o ATTR_RELOCATE
 protected static int ATTR_RELOCATE
Attribute index - The index for our relocate attribute.

 o ATTR_INDEX
 protected static int ATTR_INDEX
Attribute index - our index resource name.

 o ATTR_ICONDIR
 protected static int ATTR_ICONDIR
Attribute index - The icon directory to use in dir listing.

 o ATTR_BROWSABLE
 protected static int ATTR_BROWSABLE
Attribute index - Allow the GNN browse method.

 o ATTR_STYLE_LINK
 protected static int ATTR_STYLE_LINK
Attribute index - Style sheet for directory listing

 o dresource
 protected DirectoryResource dresource
The associated DirectoryResource (if any)

 o fresource
 protected FileResource fresource
The associated FileResource (if any)

 o acceptRanges
 protected boolean acceptRanges
Does this resource support byte ranges.

 o listing
 protected HtmlGenerator listing
Our current (cached) directory listing.

 o listing_stamp
 protected long listing_stamp
The time at which we generated the directory index.

 o browsetype
 protected static MimeType browsetype
The Browse Mime type.

Constructors

 o HTTPFrame
 public HTTPFrame()

Methods

 o registerResource
 public void registerResource(FramedResource resource)
Register this frame to the given resource.

Parameters:
resource - The resource associated with this frame.
Overrides:
registerResource in class ResourceFrame
 o getFileResource
 public FileResource getFileResource()
Get the associated FileResource (if any)

Returns:
a FileResource instance or null if no FileResource is associated with this frame.
 o getDirectoryResource
 public DirectoryResource getDirectoryResource()
Get the associated DirectoryResource (if any)

Returns:
a DirectoryResource instance or null if no DirectoryResource is associated with this frame.
 o 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.
 o 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
 o 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
 o attributeChanged
 public void attributeChanged(AttributeChangedEvent evt)
Listen its resource.

Overrides:
attributeChanged in class ResourceFrame
 o 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
 o getURL
 public URL getURL(Request request)
Get the full URL for that resource.

Returns:
An URL instance.
 o getQuality
 public double getQuality()
Get this resource quality.

Returns:
The resource quality, or some negative value if not defined.
 o getTitle
 public String getTitle()
Get this resource title.

Returns:
This resource's title, or null if not defined.
 o 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.
 o 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.
 o getContentType
 public MimeType getContentType()
Get this resource content type.

Returns:
An instance of MIMEType, or null if not defined.
 o getContentLength
 public int getContentLength()
Get this resource content length.

Returns:
The resource content length, or -1 if not defined.
 o getIcon
 public String getIcon()
Get this resource's icon.

 o 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.

 o getPutableFlag
 public boolean getPutableFlag()
Get the PUT'able flag (are we allow to PUT to the resource ?)

 o getMD5Flag
 public boolean getMD5Flag()
Do we send the MD5 digest?

 o 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).
Throws: ProtocolException
If processsing the request failed.
 o getBrowsableFlag
 public boolean getBrowsableFlag()
Get this class browsable flag.

 o getStyleSheetURL
 public String getStyleSheetURL()
Get this frame style sheet link

 o getIconDirectory
 public String getIconDirectory()
Get the optional icon directory.

 o getRelocateFlag
 public boolean getRelocateFlag()
Should we relocate invalid requests to this directory.

Returns:
A boolean true if we should relocate.
 o getIndex
 public String getIndex()
Get the optinal index name for this directory listing.

Returns:
The name of the resource responsible to list that container.
 o addStyleSheet
 public void addStyleSheet(HtmlGenerator g)
Add our own Style Sheet to the HtmlGenerator.

Parameters:
g - The HtmlGenerator.
 o getDirectoryListing
 public synchronized Reply getDirectoryListing(Request request) throws ProtocolException, ResourceException
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.
Throws: ResourceException
If the resource got a fatal error.
 o 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.

 o 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.
 o 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).
 o 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).
 o 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).
 o 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).
 o lookup
 public boolean lookup(LookupState ls,
                       LookupResult lr) throws ProtocolException
Lookup the target resource. Lookup filters and then resource.

Parameters:
ls - The current lookup state
lr - The result
Returns:
true if lookup is done.
Throws: ProtocolException
If an error relative to the protocol occurs
Overrides:
lookup in class ResourceFrame
See Also:
lookupFilters, lookupResource
 o lookupResource
 protected boolean lookupResource(LookupState ls,
                                  LookupResult lr) throws ProtocolException
Lookup the target resource (dispath to more specific lookup methods).

Parameters:
ls - The current lookup state
lr - The result
Returns:
true if lookup is done.
Throws: ProtocolException
If an error relative to the protocol occurs
See Also:
lookupDirectory, lookupFile, lookupOther
 o lookupDirectory
 protected boolean lookupDirectory(LookupState ls,
                                   LookupResult lr) throws ProtocolException
Lookup the target resource when associated with a DirectoryResource.

Parameters:
ls - The current lookup state
lr - The result
Returns:
true if lookup is done.
Throws: ProtocolException
If an error relative to the protocol occurs
 o lookupFile
 protected boolean lookupFile(LookupState ls,
                              LookupResult lr) throws ProtocolException
Lookup the target resource when associated with a FileResource.

Parameters:
ls - The current lookup state
lr - The result
Returns:
true if lookup is done.
Throws: ProtocolException
If an error relative to the protocol occurs
 o lookupOther
 protected boolean lookupOther(LookupState ls,
                               LookupResult lr) throws ProtocolException
Lookup the target resource when associated with an unknown resource.

Parameters:
ls - The current lookup state
lr - The result
Returns:
true if lookup is done.
Throws: ProtocolException
If an error relative to the protocol occurs
 o checkRequest
 public boolean checkRequest(RequestInterface request)
Check the request.

Parameters:
request - the incomming request.
Returns:
true if the request is an HTTP Request.
Overrides:
checkRequest in class ResourceFrame
 o performFrames
 protected ReplyInterface performFrames(RequestInterface request) throws ProtocolException, ResourceException
Perform the request on all the frames of that resource. The Reply returned is the first non-null reply.

Parameters:
request - A RequestInterface instance.
Returns:
A ReplyInterface instance.
Throws: ProtocolException
If an error relative to the protocol occurs
Throws: ResourceException
If an error not relative to the protocol occurs
Overrides:
performFrames in class FramedResource
 o perform
 public ReplyInterface perform(RequestInterface req) throws ProtocolException, ResourceException
Perform the request

Parameters:
req - The request to handle.
Throws: ProtocolException
If processsing the request failed.
Throws: ResourceException
If the resource got a fatal error.
Overrides:
perform in class ResourceFrame
 o get
 public Reply get(Request request) throws ProtocolException, ResourceException
The default GET method.

Parameters:
request - The request to handle.
Throws: ProtocolException
If processsing the request failed.
Throws: ResourceException
If the resource got a fatal error.
 o getOtherResource
 protected Reply getOtherResource(Request request) throws ProtocolException, ResourceException
The default GET method for other king of associated resource

Parameters:
request - The request to handle.
Throws: ProtocolException
If processsing the request failed.
Throws: ResourceException
If the resource got a fatal error.
 o createFileReply
 protected Reply createFileReply(Request request) throws ProtocolException, ResourceException
Create the reply relative to the given file.

Parameters:
request - the incomming request.
Returns:
A Reply instance
Throws: ProtocolException
If processsing the request failed.
Throws: ResourceException
If the resource got a fatal error.
 o getFileResource
 protected Reply getFileResource(Request request) throws ProtocolException, ResourceException
Get for FileResource

Parameters:
request - the incomming request.
Returns:
A Reply instance
Throws: ProtocolException
If processsing the request failed.
Throws: ResourceException
If the resource got a fatal error.
 o getDirectoryResource
 protected Reply getDirectoryResource(Request request) throws ProtocolException, ResourceException
Perform a GET for the associated DirectoryResource.

Parameters:
request - the incomming request.
Returns:
A Reply instance.
Throws: ProtocolException
if request processing failed.
Throws: ResourceException
If the resource got a fatal error.
 o head
 public Reply head(Request request) throws ProtocolException, ResourceException
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: ResourceException
If the resource got a fatal error.
 o headOtherResource
 protected Reply headOtherResource(Request request) throws ProtocolException, ResourceException
Perform a HEAD request for the associated resource.

Parameters:
request - the incomming request.
Returns:
A Reply instance
Throws: ProtocolException
If processsing the request failed.
Throws: ResourceException
If the resource got a fatal error.
 o headDirectoryResource
 protected Reply headDirectoryResource(Request request) throws ProtocolException, ResourceException
Perform a HEAD request for the associated DirectoryResource.

Parameters:
request - the incomming request.
Returns:
A Reply instance
Throws: ProtocolException
If processsing the request failed.
Throws: ResourceException
If the resource got a fatal error.
 o headFileResource
 protected Reply headFileResource(Request request) throws ProtocolException, ResourceException
Perform a HEAD request for the associated FileResource.

Parameters:
request - the incomming request.
Returns:
A Reply instance
Throws: ProtocolException
If processsing the request failed.
Throws: ResourceException
If the resource got a fatal error.
 o post
 public Reply post(Request request) throws ProtocolException, ResourceException
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: ResourceException
If the resource got a fatal error.
 o put
 public Reply put(Request request) throws ProtocolException, ResourceException
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: ResourceException
If the resource got a fatal error.
 o putOtherResource
 protected Reply putOtherResource(Request request) throws ProtocolException
Always throw a ProtocolException.

Parameters:
request - The incmming request.
Returns:
a Reply instance.
Throws: ProtocolException
(Always thrown).
 o putFileResource
 protected Reply putFileResource(Request request) throws ProtocolException, ResourceException
Change the content of the associated FileResource.

Parameters:
request - The incomming request.
Throws: ProtocolException
if a protocol error occurs
Throws: ResourceException
If the resource got a fatal error.
 o options
 public Reply options(Request request) throws ProtocolException, ResourceException
The default OPTIONS method replies with a not implemented.

Parameters:
request - The request to handle.
Throws: ProtocolException
In case of errors.
Throws: ResourceException
If the resource got a fatal error.
 o delete
 public Reply delete(Request request) throws ProtocolException, ResourceException
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: ResourceException
If the resource got a fatal error.
 o link
 public Reply link(Request request) throws ProtocolException, ResourceException
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: ResourceException
If the resource got a fatal error.
 o unlink
 public Reply unlink(Request request) throws ProtocolException, ResourceException
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: ResourceException
If the resource got a fatal error.
 o 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.
 o extended
 public Reply extended(Request request) throws ProtocolException, ResourceException
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: ResourceException
If the resource got a fatal error.
 o getBrowseType
 protected synchronized MimeType getBrowseType()
Get the Browse Mime type.

 o 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.

All Packages  Class Hierarchy  This Package  Previous  Next  Index