类 ForwardedHeaderTransformer
java.lang.Object
cn.taketoday.http.server.reactive.ForwardedHeaderTransformer
- 所有已实现的接口:
Function<ServerHttpRequest,ServerHttpRequest>
public class ForwardedHeaderTransformer
extends Object
implements Function<ServerHttpRequest,ServerHttpRequest>
Extract values from "Forwarded" and "X-Forwarded-*" headers to override
the request URI (i.e.
HttpRequest.getURI()) so it reflects
the client-originated protocol and address.
There are security considerations for forwarded headers since an application cannot know if the headers were added by a proxy, as intended, or by a malicious client. This is why a proxy at the boundary of trust should be configured to remove untrusted Forwarded headers that come from the outside.
You can also configure the ForwardedHeaderFilter with removeOnly,
in which case it removes but does not use the headers.
- 从以下版本开始:
- 4.0 2022/10/21 12:19
- 作者:
- Rossen Stoyanchev, Harry Yang
- 另请参阅:
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明private static URIadaptFromForwardedHeaders(URI uri, HttpHeaders headers) apply(ServerHttpRequest request) Apply and remove, or remove Forwarded type headers.private static StringgetForwardedPrefix(ServerHttpRequest request) protected booleanhasForwardedHeaders(ServerHttpRequest request) Whether the request has any Forwarded headers.booleanWhether the "remove only" mode is on.private voidvoidsetRemoveOnly(boolean removeOnly) Enable mode in which any "Forwarded" or "X-Forwarded-*" headers are removed only and the information in them ignored.
-
字段详细资料
-
FORWARDED_HEADER_NAMES
-
removeOnly
private boolean removeOnly
-
-
构造器详细资料
-
ForwardedHeaderTransformer
public ForwardedHeaderTransformer()
-
-
方法详细资料
-
setRemoveOnly
public void setRemoveOnly(boolean removeOnly) Enable mode in which any "Forwarded" or "X-Forwarded-*" headers are removed only and the information in them ignored.- 参数:
removeOnly- whether to discard and ignore forwarded headers
-
isRemoveOnly
public boolean isRemoveOnly()Whether the "remove only" mode is on.- 另请参阅:
-
apply
Apply and remove, or remove Forwarded type headers.- 指定者:
apply在接口中Function<ServerHttpRequest,ServerHttpRequest> - 参数:
request- the request
-
adaptFromForwardedHeaders
-
hasForwardedHeaders
Whether the request has any Forwarded headers.- 参数:
request- the request
-
removeForwardedHeaders
-
getForwardedPrefix
-