Support X-Forwarded-Prefix in ForwardedHeaderFilter
See SPR-14270
This commit is contained in:
committed by
Rossen Stoyanchev
parent
9975f02e4d
commit
7ee687c798
@@ -170,6 +170,43 @@ public class ForwardedHeaderFilterTests {
|
||||
assertEquals("bar", actual.getHeader("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestUriWithForwardedPrefix() throws Exception {
|
||||
this.request.addHeader("X-Forwarded-Prefix", "/prefix");
|
||||
this.request.setRequestURI("/mvc-showcase");
|
||||
|
||||
HttpServletRequest actual = filterAndGetWrappedRequest();
|
||||
assertEquals("http://localhost/prefix/mvc-showcase", actual.getRequestURL()
|
||||
.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void requestUriWithForwardedPrefixTrailingSlash() throws Exception {
|
||||
this.request.addHeader("X-Forwarded-Prefix", "/prefix/");
|
||||
this.request.setRequestURI("/mvc-showcase");
|
||||
|
||||
HttpServletRequest actual = filterAndGetWrappedRequest();
|
||||
assertEquals("http://localhost/prefix/mvc-showcase", actual.getRequestURL()
|
||||
.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contextPathWithForwardedPrefix() throws Exception {
|
||||
this.request.addHeader("X-Forwarded-Prefix", "/prefix");
|
||||
this.request.setContextPath("/mvc-showcase");
|
||||
|
||||
String actual = filterAndGetContextPath();
|
||||
assertEquals("/prefix/mvc-showcase", actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contextPathWithForwardedPrefixTrailingSlash() throws Exception {
|
||||
this.request.addHeader("X-Forwarded-Prefix", "/prefix/");
|
||||
this.request.setContextPath("/mvc-showcase");
|
||||
|
||||
String actual = filterAndGetContextPath();
|
||||
assertEquals("/prefix/mvc-showcase", actual);
|
||||
}
|
||||
|
||||
private String filterAndGetContextPath() throws ServletException, IOException {
|
||||
return filterAndGetWrappedRequest().getContextPath();
|
||||
|
||||
Reference in New Issue
Block a user