Skip to content

Commit

Permalink
Only generated index if enabled, else 404
Browse files Browse the repository at this point in the history
Signed-off-by: t-burch <[email protected]>
  • Loading branch information
t-burch committed Nov 8, 2023
1 parent 8a09434 commit 73ac87e
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,13 @@ public Outcome handleRequest(Exchange exc) throws Exception {
log.debug("request: " + uri);

if (escapesPath(uri) || escapesPath(router.getUriFactory().create(uri).getPath())) {

exc.setResponse(Response.badRequest().body("").build());
return Outcome.ABORT;
}

if (uri.startsWith("/"))
uri = uri.substring(1);


try {
exc.setTimeReqSent(System.currentTimeMillis());

Expand All @@ -113,8 +111,7 @@ public Outcome handleRequest(Exchange exc) throws Exception {
exc.setReceived();
exc.setTimeResReceived(System.currentTimeMillis());
return Outcome.RETURN;
} catch (ResourceRetrievalException e2) {
}
} catch (ResourceRetrievalException ignored) {}
}
String uri2 = uri + "/";
for (String i : index) {
Expand All @@ -124,20 +121,22 @@ public Outcome handleRequest(Exchange exc) throws Exception {
exc.setReceived();
exc.setTimeResReceived(System.currentTimeMillis());
return Outcome.RETURN;
} catch (ResourceRetrievalException e2) {
}
} catch (ResourceRetrievalException ignored) {}
}
}

Outcome outcome = generateHtmlResponseFromChildren(exc, uri);
if (outcome != null) {
return outcome;
if (generateIndex) {
Outcome outcome = generateHtmlResponseFromChildren(exc, uri);
if (outcome != null) {
return outcome;
}
}

exc.setResponse(Response.notFound().build());
return Outcome.ABORT;
}


private Outcome generateHtmlResponseFromChildren(Exchange exc, String uri) throws FileNotFoundException {
List<String> children = router.getResolverMap().getChildren(ResolverMap.combine(router.getBaseLocation(), docBase, uri));
if (children == null) {
Expand Down

0 comments on commit 73ac87e

Please sign in to comment.