Skip to content

Commit

Permalink
Issue #7748 - allow override of path mapping behavior in ServletConte…
Browse files Browse the repository at this point in the history
…xtHandler (#7614)

Added protected method to ServletHandler to allow other servlet mappings (eg regex) in embedded/extended usage

Signed-off-by: Greg Wilkins <gregw@webtide.com>
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
gregw authored and joakime committed Oct 6, 2022
1 parent f9616fe commit 024a053
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Expand Up @@ -85,12 +85,6 @@ public ServletPathMapping(PathSpec pathSpec, String servletName, String pathInCo
break;

case MIDDLE_GLOB:
_mappingMatch = null;
_matchValue = "";
_servletPath = pathInContext;
_pathInfo = null;
break;

default:
throw new IllegalStateException();
}
Expand All @@ -104,6 +98,7 @@ else if (pathSpec != null)
}
else
{
// TODO can we do better for RegexPathSpec
_mappingMatch = null;
_matchValue = "";
_servletPath = pathInContext;
Expand Down
Expand Up @@ -1287,6 +1287,7 @@ protected void updateNameMappings()

protected PathSpec asPathSpec(String pathSpec)
{
// By default only allow servlet path specs
return new ServletPathSpec(pathSpec);
}

Expand Down
Expand Up @@ -79,7 +79,7 @@ public void testMapping() throws Exception
assertThat(response, containsString("servletPath='/test/info'"));
assertThat(response, containsString("pathInfo='null'"));
assertThat(response, containsString("mapping.mappingMatch='null'"));
assertThat(response, containsString("mapping.matchValue='test/info'"));
assertThat(response, containsString("mapping.matchValue=''"));
assertThat(response, containsString("mapping.pattern='^/test/.*$'"));
}

Expand All @@ -93,10 +93,10 @@ public void testForward() throws Exception
String response = _connector.getResponse("GET /ctx/forward/ignore HTTP/1.0\r\n\r\n");
assertThat(response, containsString(" 200 OK"));
assertThat(response, containsString("contextPath='/ctx'"));
assertThat(response, containsString("servletPath='/Test'"));
assertThat(response, containsString("pathInfo='/info'"));
assertThat(response, containsString("servletPath='/Test/info'"));
assertThat(response, containsString("pathInfo='null'"));
assertThat(response, containsString("mapping.mappingMatch='null'"));
assertThat(response, containsString("mapping.matchValue='Test'"));
assertThat(response, containsString("mapping.matchValue=''"));
assertThat(response, containsString("mapping.pattern='^/[Tt]est(/.*)?'"));
}

Expand All @@ -113,7 +113,7 @@ public void testInclude() throws Exception
assertThat(response, containsString("servletPath='/include'"));
assertThat(response, containsString("pathInfo='null'"));
assertThat(response, containsString("mapping.mappingMatch='null'"));
assertThat(response, containsString("mapping.matchValue='include'"));
assertThat(response, containsString("mapping.matchValue=''"));
assertThat(response, containsString("mapping.pattern='^/include$'"));
}

Expand Down

0 comments on commit 024a053

Please sign in to comment.