Also apply X-Forwarded-Prefix in fromContextPath
Issue: SPR-12500
This commit is contained in:
@@ -176,6 +176,15 @@ public class ServletUriComponentsBuilderTests {
|
||||
assertEquals("http://localhost/mvc-showcase", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromContextPathWithForwardedPrefix() {
|
||||
request.addHeader("X-Forwarded-Prefix", "/prefix");
|
||||
request.setContextPath("/mvc-showcase");
|
||||
request.setRequestURI("/mvc-showcase/simple");
|
||||
String result = ServletUriComponentsBuilder.fromContextPath(request).build().toUriString();
|
||||
assertEquals("http://localhost/prefix/mvc-showcase", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromServletMapping() {
|
||||
request.setRequestURI("/mvc-showcase/app/simple");
|
||||
@@ -185,6 +194,16 @@ public class ServletUriComponentsBuilderTests {
|
||||
assertEquals("http://localhost/mvc-showcase/app", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromServletMappingWithForwardedPrefix() {
|
||||
request.addHeader("X-Forwarded-Prefix", "/prefix");
|
||||
request.setContextPath("/mvc-showcase");
|
||||
request.setServletPath("/app");
|
||||
request.setRequestURI("/mvc-showcase/app/simple");
|
||||
String result = ServletUriComponentsBuilder.fromServletMapping(request).build().toUriString();
|
||||
assertEquals("http://localhost/prefix/mvc-showcase/app", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromCurrentRequest() {
|
||||
request.setRequestURI("/mvc-showcase/data/param");
|
||||
|
||||
Reference in New Issue
Block a user