ForwardedHeaderFilter is case-insensitive
Issue: SPR-14372
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.web.servlet.support;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.http.HttpRequest;
|
||||
@@ -133,8 +134,15 @@ public class ServletUriComponentsBuilder extends UriComponentsBuilder {
|
||||
}
|
||||
|
||||
private static String prependForwardedPrefix(HttpServletRequest request, String path) {
|
||||
String prefix = request.getHeader("X-Forwarded-Prefix");
|
||||
if (StringUtils.hasText(prefix)) {
|
||||
String prefix = null;
|
||||
Enumeration<String> names = request.getHeaderNames();
|
||||
while (names.hasMoreElements()) {
|
||||
String name = names.nextElement();
|
||||
if ("X-Forwarded-Prefix".equalsIgnoreCase(name)) {
|
||||
prefix = request.getHeader(name);
|
||||
}
|
||||
}
|
||||
if (prefix != null) {
|
||||
path = prefix + path;
|
||||
}
|
||||
return path;
|
||||
|
||||
Reference in New Issue
Block a user