| net.homeip.donaldm.httpdbase4j.HttpHandleable
All known Subclasses: net.homeip.donaldm.httpdbase4j.FileStringTemplateHandler, net.homeip.donaldm.httpdbase4j.ArchiveHttpd, net.homeip.donaldm.httpdbase4j.ArchiveStringTemplateHandler, net.homeip.donaldm.httpdbase4j.Httpd, net.homeip.donaldm.httpdbase4j.FileHttpd, net.homeip.donaldm.httpdbase4j.StringTemplateHandler,
HttpHandleable | public interface HttpHandleable (Code) | | Interface with all the overidable methods that handlers provide.
author: Donald Munro |
Method Summary | |
public Request | onFileNotFound(long id, HttpExchange ex, Request request) Called when a request file is not found.
Parameters: id - Unique transaction id Parameters: ex - The exchange instance for the current HTTP transaction. Parameters: request - The request instance Return null to process normally ie return a 404 error, otherwise return a new Request to be processed which will be used instead of request. | public File | onGetCachedFile(long id, HttpExchange ex, Request request) Called to retrieve a cached file if a user defined caching scheme is
used. | public boolean | onIsCacheable(long id, HttpExchange ex, Request request) Called to determine whether the resource from a request should be cached. | public String | onListDirectory(Request request) Called to list a directory request. | public void | onPostServe(long id, HttpExchange ex, Request request, boolean isOK) Called before the server performs a GETon a file. | public boolean | onPreServe(long id, HttpExchange ex, Request request) Called before the server serves a file. | public InputStream | onServeBody(long id, HttpExchange ex, Request request) Called as the server is about to send the GET data. | public HttpResponse | onServeHeaders(long id, HttpExchange ex, Request request) Called as the server is about to perform a GET. |
onFileNotFound | public Request onFileNotFound(long id, HttpExchange ex, Request request)(Code) | | Called when a request file is not found.
Parameters: id - Unique transaction id Parameters: ex - The exchange instance for the current HTTP transaction. Parameters: request - The request instance Return null to process normally ie return a 404 error, otherwise return a new Request to be processed which will be used instead of request. |
onGetCachedFile | public File onGetCachedFile(long id, HttpExchange ex, Request request)(Code) | | Called to retrieve a cached file if a user defined caching scheme is
used.
Parameters: id - Unique id Parameters: ex - The exchange instance for the current HTTP transaction. Parameters: request - The request instance true to cache the result, false to not cache. |
onIsCacheable | public boolean onIsCacheable(long id, HttpExchange ex, Request request)(Code) | | Called to determine whether the resource from a request should be cached.
To implement user defined cacheing cache the file but return false and
also overide @see onGetCachedFile to return the cached file.
Parameters: id - Unique id Parameters: ex - The exchange instance for the current HTTP transaction. Parameters: request - The request instance true to cache the result, false to not cache. |
onListDirectory | public String onListDirectory(Request request)(Code) | | Called to list a directory request.
Parameters: request - A String containing the HTML for a page listing the directory contents for a directory request. |
onPostServe | public void onPostServe(long id, HttpExchange ex, Request request, boolean isOK)(Code) | | Called before the server performs a GETon a file. May be used by an
overiding class to generate dynamic content. The overiding class should
return a new File or if it does not generate a new file then it should
return the input File parameter
Parameters: id - Unique transaction id Parameters: ex - The exchange instance for the current HTTP transaction. Parameters: request - The request instance Parameters: isOK - true if the request has been successfully sent |
onPreServe | public boolean onPreServe(long id, HttpExchange ex, Request request)(Code) | | Called before the server serves a file.
Parameters: id - Unique id Parameters: ex - The exchange instance for the current HTTP transaction. Parameters: request - The request instance true to continue processing the request |
onServeBody | public InputStream onServeBody(long id, HttpExchange ex, Request request)(Code) | | Called as the server is about to send the GET data. May be used by an
overiding class to modify the data. The overiding class should
return a InputStream from which to read the or null to use the default.
Parameters: id - Unique transaction id Parameters: ex - The exchange instance for the current HTTP transaction. Parameters: request - The request instance Return null to process normally, else return the HttpResponse to be send to the client |
onServeHeaders | public HttpResponse onServeHeaders(long id, HttpExchange ex, Request request)(Code) | | Called as the server is about to perform a GET. May be used by an
overiding class to modify the response headers. The overiding class should
return a HttpResponse or null to use the default HttpResponse.
NOTE: If the overiding class is going to alter the response body
using onGETBody then it should set the Content-Length header in
this method.
Parameters: id - Unique transaction id Parameters: ex - The exchange instance for the current HTTP transaction. Parameters: request - The request instance Return null to process normally, otherwise return a new HttpResponse to be send to the client |
|
|