mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Use X-Forwarded-Prefix in ServletUriComponentsBuilder
Issue: SPR-12500
This commit is contained in:
+18
@@ -150,6 +150,24 @@ public class ServletUriComponentsBuilderTests {
|
||||
assertEquals("should have used the default port of the forwarded request", -1, result.getPort());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromRequestWithForwardedPrefix() {
|
||||
this.request.setRequestURI("/bar");
|
||||
this.request.addHeader("X-Forwarded-Prefix", "/foo");
|
||||
UriComponents result = ServletUriComponentsBuilder.fromRequest(request).build();
|
||||
|
||||
assertEquals("http://localhost/foo/bar", result.toUriString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromRequestWithForwardedPrefixTrailingSlash() {
|
||||
this.request.setRequestURI("/bar");
|
||||
this.request.addHeader("X-Forwarded-Prefix", "/foo/");
|
||||
UriComponents result = ServletUriComponentsBuilder.fromRequest(request).build();
|
||||
|
||||
assertEquals("http://localhost/foo/bar", result.toUriString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fromContextPath() {
|
||||
request.setRequestURI("/mvc-showcase/data/param");
|
||||
|
||||
Reference in New Issue
Block a user