Note
There are security considerations surrounding the use of forwarded headers. Those should not be used unless the application is behind a trusted proxy that inserts them and also explicitly removes any such headers coming from an external source.
In most cases, you should not use this class directly but rather rely on
org. for Spring MVC or
org. in
order to extract the information from the headers as early as possible and discard
such headers. Underlying servers such as Tomcat, Jetty, and Reactor Netty also
provide options to handle forwarded headers even earlier.
| Modifier and Type | Field and Description |
|---|---|
| private static final Pattern | |
| private static final Pattern | |
| private static final Pattern | |
| private static final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| public static UriComponentsBuilder | Returns: aUriComponentsBuilder that reflects the request URI and
additional updates from forwarded headersthe request uri, HttpHeaders URIthe HTTP headers to consider headers)Adapt the scheme+host+port of the given |
| private static boolean | |
| public static InetSocketAddress | Returns: anInetSocketAddress with the extracted host and port, or
null if the headers are not presentthe request uri, HttpHeaders URIthe request headers that may contain forwarded headers headers, InetSocketAddress the current remote address remoteAddress)Parse the first "Forwarded: for=..." or "X-Forwarded-For" header value to
an |
| FORWARDED_FOR_PATTERN | back to summary |
|---|---|
| private static final Pattern FORWARDED_FOR_PATTERN | |
| FORWARDED_HOST_PATTERN | back to summary |
|---|---|
| private static final Pattern FORWARDED_HOST_PATTERN | |
| FORWARDED_PROTO_PATTERN | back to summary |
|---|---|
| private static final Pattern FORWARDED_PROTO_PATTERN | |
| FORWARDED_VALUE | back to summary |
|---|---|
| private static final String FORWARDED_VALUE | |
| ForwardedHeaderUtils | back to summary |
|---|---|
| public ForwardedHeaderUtils() | |
| adaptForwardedHost | back to summary |
|---|---|
| private static void adaptForwardedHost(UriComponentsBuilder uriComponentsBuilder, String rawValue) | |
| adaptFromForwardedHeaders | back to summary |
|---|---|
| public static UriComponentsBuilder adaptFromForwardedHeaders(URI uri, HttpHeaders headers) Adapt the scheme+host+port of the given
| |
| isForwardedSslOn | back to summary |
|---|---|
| private static boolean isForwardedSslOn(HttpHeaders headers) | |
| parseForwardedFor | back to summary |
|---|---|
| public static InetSocketAddress parseForwardedFor(URI uri, HttpHeaders headers, InetSocketAddress remoteAddress) Parse the first "Forwarded: for=..." or "X-Forwarded-For" header value to
an
| |