private void sendDirectory(RoutingContext context, String path, String file) { if (directoryListing) { sendDirectoryListing(file, context); } else if (indexPage != null) { // send index page String indexPath; if (path.endsWith("/") && indexPage.startsWith("/")) { indexPath = path + indexPage.substring(1); } else if (!path.endsWith("/") && !indexPage.startsWith("/")) { indexPath = path + "/" + indexPage.substring(1); } else { indexPath = path + indexPage; } // recursive call sendStatic(context, indexPath); } else { // Directory listing denied context.fail(FORBIDDEN.code()); } }
@Override public void handle(RoutingContext context) { HttpServerRequest request = context.request(); if (request.method() != HttpMethod.GET && request.method() != HttpMethod.HEAD) { if (log.isTraceEnabled()) log.trace("Not GET or HEAD so ignoring request"); context.next(); } else { String path = HttpUtils.removeDots(URIDecoder.decodeURIComponent(context.normalisedPath(), false)); // if the normalized path is null it cannot be resolved if (path == null) { log.warn("Invalid path: " + context.request().path()); context.next(); return; } // only root is known for sure to be a directory. all other directories must be identified as such. if (!directoryListing && "/".equals(path)) { path = indexPage; } // can be called recursive for index pages sendStatic(context, path); } }
private void sendDirectory(RoutingContext context, String path, String file) { if (directoryListing) { sendDirectoryListing(file, context); } else if (indexPage != null) { // send index page String indexPath; if (path.endsWith("/") && indexPage.startsWith("/")) { indexPath = path + indexPage.substring(1); } else if (!path.endsWith("/") && !indexPage.startsWith("/")) { indexPath = path + "/" + indexPage.substring(1); } else { indexPath = path + indexPage; } // recursive call sendStatic(context, indexPath); } else { // Directory listing denied context.fail(FORBIDDEN.code()); } }
@Override public void handle(RoutingContext context) { HttpServerRequest request = context.request(); if (request.method() != HttpMethod.GET && request.method() != HttpMethod.HEAD) { if (log.isTraceEnabled()) log.trace("Not GET or HEAD so ignoring request"); context.next(); } else { String path = HttpUtils.removeDots(URIDecoder.decodeURIComponent(context.normalisedPath(), false)); // if the normalized path is null it cannot be resolved if (path == null) { log.warn("Invalid path: " + context.request().path()); context.next(); return; } // only root is known for sure to be a directory. all other directories must be identified as such. if (!directoryListing && "/".equals(path)) { path = indexPage; } // can be called recursive for index pages sendStatic(context, path); } }