public class ForwardedHeaderFilter extends java.lang.Object implements WebFilter
HttpRequest.getURI()
.
In effect the request URI will reflect the client-originated
protocol and address.
Note: This filter can also be used in a
removeOnly
mode where "Forwarded" and "X-Forwarded-*"
headers are only eliminated without being used.
Modifier and Type | Field and Description |
---|---|
private static java.util.Set<java.lang.String> |
FORWARDED_HEADER_NAMES |
private boolean |
removeOnly |
Constructor and Description |
---|
ForwardedHeaderFilter() |
Modifier and Type | Method and Description |
---|---|
<any> |
filter(ServerWebExchange exchange,
WebFilterChain chain)
Process the Web request and (optionally) delegate to the next
WebFilter through the given WebFilterChain . |
private static java.lang.String |
getForwardedPrefix(HttpHeaders headers) |
void |
setRemoveOnly(boolean removeOnly)
Enables mode in which any "Forwarded" or "X-Forwarded-*" headers are
removed only and the information in them ignored.
|
private boolean |
shouldNotFilter(ServerHttpRequest request) |
private static final java.util.Set<java.lang.String> FORWARDED_HEADER_NAMES
private boolean removeOnly
public void setRemoveOnly(boolean removeOnly)
removeOnly
- whether to discard and ignore forwarded headerspublic <any> filter(ServerWebExchange exchange, WebFilterChain chain)
WebFilter
WebFilter
through the given WebFilterChain
.private boolean shouldNotFilter(ServerHttpRequest request)
@Nullable private static java.lang.String getForwardedPrefix(HttpHeaders headers)