类 ForwardedHeaderTransformer
- java.lang.Object
- org.springframework.web.server.adapter.ForwardedHeaderTransformer
- 所有已实现的接口:
Function<ServerHttpRequest,ServerHttpRequest>
- 直接已知子类:
ForwardedHeaderFilter
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.Alternatively if
removeOnly
is set to "true", then "Forwarded" and "X-Forwarded-*" headers are only removed, and not used.An instance of this class is typically declared as a bean with the name "forwardedHeaderTransformer" and detected by
WebHttpHandlerBuilder.applicationContext(ApplicationContext)
, or it can also be registered directly viaWebHttpHandlerBuilder.forwardedHeaderTransformer(ForwardedHeaderTransformer)
.- 从以下版本开始:
- 5.1
- 作者:
- Rossen Stoyanchev
- 另请参阅:
- https://tools.ietf.org/html/rfc7239
构造器概要
构造器 构造器 说明 ForwardedHeaderTransformer()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ServerHttpRequest
apply(ServerHttpRequest request)
Apply and remove, or remove Forwarded type headers.protected boolean
hasForwardedHeaders(ServerHttpRequest request)
Whether the request has any Forwarded headers.boolean
isRemoveOnly()
Whether the "remove only" mode is on.void
setRemoveOnly(boolean removeOnly)
Enable mode in which any "Forwarded" or "X-Forwarded-*" headers are removed only and the information in them ignored.
构造器详细资料
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
public ServerHttpRequest apply(ServerHttpRequest request)
Apply and remove, or remove Forwarded type headers.- 指定者:
apply
在接口中Function<ServerHttpRequest,ServerHttpRequest>
- 参数:
request
- the request
hasForwardedHeaders
protected boolean hasForwardedHeaders(ServerHttpRequest request)
Whether the request has any Forwarded headers.- 参数:
request
- the request