|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objectorg.xlightweb.FileServiceRequestHandler
public class FileServiceRequestHandler
Handler implementation to handle file requests. If the requested file does not exists, the
handler will forward the request. If the handler is embedded within RequestHandlerChain
the next handler will be called. If no successor exists, a 404 will be returned.
If the flag isShowDirectoryTree is set (default is false) the directory tree will be
printed, in case the request file does not exists. See example:
String basePath = "public/files"; IHttpRequestHandler handler = new FileServiceRequestHandler(basePath, true); // will show the directory tree, if a directory is requested IServer server = new HttpServer(8080, handler); server.start();
| Field Summary | |
|---|---|
static boolean |
SHOW_DIRECTORY_TREE_DEFAULT
|
| Fields inherited from interface org.xlightweb.IHttpRequestHandler |
|---|
DEFAULT_EXECUTION_MODE, DEFAULT_INVOKE_ON_MODE, DEFAULT_SYNCHRONIZED_ON_MODE |
| Constructor Summary | |
|---|---|
FileServiceRequestHandler(String fileBasepath)
constructor |
|
FileServiceRequestHandler(String fileBasepath,
boolean isShowDirectoryTree)
constructor |
|
FileServiceRequestHandler(String fileBasepath,
Integer expireSec)
constructor |
|
FileServiceRequestHandler(String fileBasepath,
Integer expireSec,
boolean isShowDirectoryTree)
constructor |
|
| Method Summary | |
|---|---|
void |
onRequest(IHttpExchange exchange)
call back method, which will be called if a request message (header) is received |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final boolean SHOW_DIRECTORY_TREE_DEFAULT
| Constructor Detail |
|---|
public FileServiceRequestHandler(String fileBasepath)
throws FileNotFoundException
fileBasepath - the base path
FileNotFoundException - if the base path not exists
public FileServiceRequestHandler(String fileBasepath,
Integer expireSec)
throws FileNotFoundException
fileBasepath - the base pathexpireSec - the expire time sec, which will be added to each response for caching or null
FileNotFoundException - if the base path not exists
public FileServiceRequestHandler(String fileBasepath,
boolean isShowDirectoryTree)
throws FileNotFoundException
fileBasepath - the base pathisShowDirectoryTree - true, if the directory tree will been shown, if the requests file is a directory
FileNotFoundException - if the base path not exists
public FileServiceRequestHandler(String fileBasepath,
Integer expireSec,
boolean isShowDirectoryTree)
throws FileNotFoundException
fileBasepath - the base pathexpireSec - the expire time sec, which will be added to each response for caching or nullisShowDirectoryTree - true, if the directory tree will been shown, if the requests file is a directory
FileNotFoundException - if the base path not exists| Method Detail |
|---|
public void onRequest(IHttpExchange exchange)
throws IOException,
BadMessageException
IHttpRequestHandler
onRequest in interface IHttpRequestHandlerexchange - the exchange contains the request from the client is used to send the response
IOException - if an exception occurred. By throwing this exception an error http response message
will be sent by xSocket, if one or more requests are unanswered. The underlying
connection will be closed
BadMessageException - By throwing this exception an error http response message will be sent by xSocket,
which contains the exception message. The underlying connection will be closed
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||