@@ -37,21 +37,22 @@ public Response respond(AppConfig appConfig, Request request) throws IOException
3737 String requestPathString = request .getPathString ();
3838
3939 if (specialCaseRouteMap .hasRoute (requestPathString )) {
40- return specialCaseRouteMap .getResponderForRoute (requestPathString ).respond (appConfig , request );
40+ Responder responderForRoute = specialCaseRouteMap .getResponderForRoute (requestPathString );
41+ return responderForRoute .respond (appConfig , request );
4142 }
4243
4344 Path root = appConfig .getRoot ();
44- Path path = pathExaminer .getFullPath (root , requestPathString );
45-
46- if (pathExaminer .pathExists (path )) {
47- if ( pathExaminer . isFile ( path )) {
48- return responseForFile ( path , request );
49- } else {
50- return responseForDir ( root , path );
51- }
45+ Path fullPath = pathExaminer .getFullPath (root , requestPathString );
46+
47+ if (! pathExaminer .pathExists (fullPath )) {
48+ return new NotFoundResponse ();
49+ }
50+
51+ if (! pathExaminer . isFile ( fullPath )) {
52+ return responseForDir ( root , fullPath );
5253 }
5354
54- return new NotFoundResponse ( );
55+ return responseForFile ( fullPath , request );
5556 }
5657
5758 private Response responseForDir (Path root , Path path ) {
@@ -61,17 +62,18 @@ private Response responseForDir(Path root, Path path) {
6162 }
6263
6364 private String htmlLinksForContents (Path root , Path [] paths ) {
64- String result = "" ;
65+ StringBuilder stringBuilder = new StringBuilder () ;
6566 for (Path subPath : paths ) {
66- result = result + html .linkString (root , subPath );
67+ stringBuilder . append ( html .linkString (root , subPath ) );
6768 }
68- return result ;
69+ return stringBuilder . toString () ;
6970 }
7071
7172 private Response responseForFile (Path path , Request request ) {
7273 byte [] payload = pathExaminer .fileContents (path );
7374
74- Response response = null ;
75+ Response response ;
76+
7577 if (request .hasHeader ("Range" )) {
7678 String rangeHeaderValue = request .getHeaderValue ("Range" );
7779 Range range = rangeHeaderValueParser .parse (rangeHeaderValue , payload .length );
0 commit comments