|
|
|
@ -307,41 +307,41 @@ public class ForwardedHeaderFilter extends OncePerRequestFilter { |
|
|
|
this.request = request; |
|
|
|
this.request = request; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void sendRedirect(String location) throws IOException { |
|
|
|
public void sendRedirect(String location) throws IOException { |
|
|
|
|
|
|
|
|
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(location); |
|
|
|
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(location); |
|
|
|
UriComponents uriComponents = builder.build(); |
|
|
|
UriComponents uriComponents = builder.build(); |
|
|
|
|
|
|
|
|
|
|
|
// Absolute location
|
|
|
|
// Absolute location
|
|
|
|
if (uriComponents.getScheme() != null) { |
|
|
|
if (uriComponents.getScheme() != null) { |
|
|
|
super.sendRedirect(location); |
|
|
|
super.sendRedirect(location); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Network-path reference
|
|
|
|
// Network-path reference
|
|
|
|
if (location.startsWith("//")) { |
|
|
|
if (location.startsWith("//")) { |
|
|
|
String scheme = this.request.getScheme(); |
|
|
|
String scheme = this.request.getScheme(); |
|
|
|
super.sendRedirect(builder.scheme(scheme).toUriString()); |
|
|
|
super.sendRedirect(builder.scheme(scheme).toUriString()); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String path = uriComponents.getPath(); |
|
|
|
String path = uriComponents.getPath(); |
|
|
|
if (path != null) { |
|
|
|
if (path != null) { |
|
|
|
// Relative to Servlet container root or to current request
|
|
|
|
// Relative to Servlet container root or to current request
|
|
|
|
path = (path.startsWith(FOLDER_SEPARATOR) ? path : |
|
|
|
path = (path.startsWith(FOLDER_SEPARATOR) ? path : |
|
|
|
StringUtils.applyRelativePath(this.request.getRequestURI(), path)); |
|
|
|
StringUtils.applyRelativePath(this.request.getRequestURI(), path)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String result = UriComponentsBuilder |
|
|
|
String result = UriComponentsBuilder |
|
|
|
.fromHttpRequest(new ServletServerHttpRequest(this.request)) |
|
|
|
.fromHttpRequest(new ServletServerHttpRequest(this.request)) |
|
|
|
.replacePath(path) |
|
|
|
.replacePath(path) |
|
|
|
.replaceQuery(uriComponents.getQuery()) |
|
|
|
.replaceQuery(uriComponents.getQuery()) |
|
|
|
.fragment(uriComponents.getFragment()) |
|
|
|
.fragment(uriComponents.getFragment()) |
|
|
|
.build().normalize().toUriString(); |
|
|
|
.build().normalize().toUriString(); |
|
|
|
|
|
|
|
|
|
|
|
super.sendRedirect(result); |
|
|
|
super.sendRedirect(result); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|