Package reactor.netty.http.server
Class ConnectionInfo
java.lang.Object
reactor.netty.http.server.ConnectionInfo
Resolve information about the current connection, including the
host (server) address, the remote (client) address and the scheme.
Depending on the chosen factory method, the information
can be retrieved directly from the channel or additionally
using the "Forwarded", or "X-Forwarded-*"
HTTP request headers.
- Since:
- 0.8
- Author:
- Brian Clozel, Andrey Shlykov
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic intgetDefaultHostPort(String scheme) Returns the default host port number based on scheme.@Nullable StringReturns the X-Forwarded-Prefix if it was part of the request headers.@Nullable InetSocketAddressReturn the host address of the connection.Returns the connection host name.intReturns the connection host port.@Nullable InetSocketAddressReturn the remote address of the connection.Return the connection scheme.withForwardedPrefix(String forwardedPrefix) Return a newConnectionInfowith the forwardedPrefix set.withHostAddress(InetSocketAddress hostAddress) Return a newConnectionInfowith the updated host address.withHostAddress(InetSocketAddress hostAddress, String hostName, int hostPort) Return a newConnectionInfowith updated host address, host name, and host port information.withRemoteAddress(InetSocketAddress remoteAddress) Return a newConnectionInfowith the updated remote address.withScheme(String scheme) Return a newConnectionInfowith the updated scheme.
-
Method Details
-
getHostAddress
Return the host address of the connection.- Returns:
- the host address
-
getRemoteAddress
Return the remote address of the connection.- Returns:
- the remote address
-
getScheme
Return the connection scheme.- Returns:
- the connection scheme
-
withHostAddress
Return a newConnectionInfowith the updated host address.- Parameters:
hostAddress- the host address- Returns:
- a new
ConnectionInfo
-
withHostAddress
Return a newConnectionInfowith updated host address, host name, and host port information.- Parameters:
hostAddress- the updated host addresshostName- the updated host namehostPort- the updated host port- Returns:
- a new
ConnectionInfo - Since:
- 1.0.32
-
withRemoteAddress
Return a newConnectionInfowith the updated remote address.- Parameters:
remoteAddress- the remote address- Returns:
- a new
ConnectionInfo
-
withScheme
Return a newConnectionInfowith the updated scheme.- Parameters:
scheme- the connection scheme- Returns:
- a new
ConnectionInfo
-
withForwardedPrefix
Return a newConnectionInfowith the forwardedPrefix set.- Parameters:
forwardedPrefix- the prefix provided via X-Forwarded-Prefix header- Returns:
- a new
ConnectionInfo - Since:
- 1.1.23
-
getHostName
Returns the connection host name.- Returns:
- the connection host name
- Since:
- 1.0.32
-
getHostPort
public int getHostPort()Returns the connection host port.- Returns:
- the connection host port
- Since:
- 1.0.32
-
getForwardedPrefix
Returns the X-Forwarded-Prefix if it was part of the request headers.- Returns:
- the X-Forwarded-Prefix
- Since:
- 1.1.23
-
getDefaultHostPort
Returns the default host port number based on scheme.- Parameters:
scheme- a connection scheme like "http", "https", or "wss"- Returns:
- the default host port number based on scheme
- Since:
- 1.0.32
-