Issue #1737 - fixing up ResourceHandler behavior with welcome files

This commit is contained in:
Joakim Erdfelt 2017-08-16 09:34:07 -07:00
parent a472546bd0
commit 9c7af33806
2 changed files with 4 additions and 4 deletions

View File

@ -91,15 +91,15 @@ public class ResourceHandler extends HandlerWrapper implements ResourceFactory,W
if (_welcomes == null) if (_welcomes == null)
return null; return null;
String welcome_servlet = null;
for (int i = 0; i < _welcomes.length; i++) for (int i = 0; i < _welcomes.length; i++)
{ {
String welcome_in_context = URIUtil.addPaths(pathInContext,_welcomes[i]); String welcome_in_context = URIUtil.addPaths(pathInContext,_welcomes[i]);
Resource welcome = getResource(welcome_in_context); Resource welcome = getResource(welcome_in_context);
if (welcome != null && welcome.exists()) if (welcome != null && welcome.exists())
return _welcomes[i]; return welcome_in_context;
} }
return welcome_servlet; // not found
return null;
} }

View File

@ -254,7 +254,7 @@ public class ResourceHandlerTest
HttpTester.Response response = HttpTester.parseResponse( HttpTester.Response response = HttpTester.parseResponse(
_local.getResponse("GET /resource/directory/ HTTP/1.0\r\n\r\n")); _local.getResponse("GET /resource/directory/ HTTP/1.0\r\n\r\n"));
assertThat(response.getStatus(),equalTo(302)); assertThat(response.getStatus(),equalTo(302));
assertThat(response.get(LOCATION),containsString("/resource/welcome.txt")); assertThat(response.get(LOCATION),containsString("/resource/directory/welcome.txt"));
} }
finally finally
{ {