| | |
| | | public static final String WELCOME_FILE = "index.html"; |
| | | |
| | | /* Ablageort fuer Webinhalte */ |
| | | protected final String fileBase; |
| | | //protected final String fileBase; |
| | | |
| | | public static final String ATTR_FILE_BASE = "fileBase"; |
| | | |
| | | /** |
| | | * Ein neues Objekt der Klasse FileHandler erzeugen |
| | |
| | | * Ordners im Dateisystem, der die Inhalte enthaelt, die von diesem |
| | | * Handler ausgeliefert werden sollen |
| | | */ |
| | | /* |
| | | public FileHandler(String absoluteDirectoryPathAndName) { |
| | | this.fileBase = absoluteDirectoryPathAndName; |
| | | } |
| | | */ |
| | | |
| | | /** |
| | | * Die Datei ermitteln, die sich aus dem angefragten URL ergibt, prüfen, |
| | |
| | | Headers headers = e.getRequestHeaders(); |
| | | if (headers.containsKey(RANGE_HEADER)) { |
| | | FileActor fa = new FileActor(); |
| | | fa.serveFileParts(e, new File(fileBase, fName)); |
| | | fa.serveFileParts(e, new File(e.getHttpContext().getAttributes().get(ATTR_FILE_BASE).toString(), fName)); |
| | | } else { |
| | | if (fName.length() < 1 || fName.endsWith(STR_SLASH)) { |
| | | fName += WELCOME_FILE; |
| | | } |
| | | HttpResponder fs = new HttpResponder(); |
| | | fs.serveFile(e, new File(fileBase, fName)); |
| | | fs.serveFile(e, new File(e.getHttpContext().getAttributes().get(ATTR_FILE_BASE).toString(), fName)); |
| | | } |
| | | } |
| | | } |
| | |
| | | return uriPath.substring(ctxPath.length()); |
| | | } |
| | | |
| | | public String getFileBase() { |
| | | return this.fileBase; |
| | | } |
| | | /*public String getFileBase() { |
| | | return this.e.getHttpContext().getAttributes().get(ATTR_FILE_BASE).toString(); |
| | | }*/ |
| | | |
| | | } |