public final class ConnectionInfo extends Object
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.
Modifier and Type | Method and Description |
---|---|
static int |
getDefaultHostPort(String scheme)
Returns the default host port number based on scheme.
|
String |
getForwardedPrefix()
Returns the X-Forwarded-Prefix if it was part of the request headers.
|
InetSocketAddress |
getHostAddress()
Return the host address of the connection.
|
String |
getHostName()
Returns the connection host name.
|
int |
getHostPort()
Returns the connection host port.
|
InetSocketAddress |
getRemoteAddress()
Return the remote address of the connection.
|
String |
getScheme()
Return the connection scheme.
|
ConnectionInfo |
withForwardedPrefix(String forwardedPrefix)
Return a new
ConnectionInfo with the forwardedPrefix set. |
ConnectionInfo |
withHostAddress(InetSocketAddress hostAddress)
Return a new
ConnectionInfo with the updated host address. |
ConnectionInfo |
withHostAddress(InetSocketAddress hostAddress,
String hostName,
int hostPort)
Return a new
ConnectionInfo with updated host address, host name, and host port information. |
ConnectionInfo |
withRemoteAddress(InetSocketAddress remoteAddress)
Return a new
ConnectionInfo with the updated remote address. |
ConnectionInfo |
withScheme(String scheme)
Return a new
ConnectionInfo with the updated scheme. |
@Nullable public InetSocketAddress getHostAddress()
@Nullable public InetSocketAddress getRemoteAddress()
public String getScheme()
public ConnectionInfo withHostAddress(InetSocketAddress hostAddress)
ConnectionInfo
with the updated host address.hostAddress
- the host addressConnectionInfo
public ConnectionInfo withHostAddress(InetSocketAddress hostAddress, String hostName, int hostPort)
ConnectionInfo
with updated host address, host name, and host port information.hostAddress
- the updated host addresshostName
- the updated host namehostPort
- the updated host portConnectionInfo
public ConnectionInfo withRemoteAddress(InetSocketAddress remoteAddress)
ConnectionInfo
with the updated remote address.remoteAddress
- the remote addressConnectionInfo
public ConnectionInfo withScheme(String scheme)
ConnectionInfo
with the updated scheme.scheme
- the connection schemeConnectionInfo
public ConnectionInfo withForwardedPrefix(String forwardedPrefix)
ConnectionInfo
with the forwardedPrefix set.forwardedPrefix
- the prefix provided via X-Forwarded-Prefix headerConnectionInfo
public String getHostName()
public int getHostPort()
@Nullable public String getForwardedPrefix()
public static int getDefaultHostPort(String scheme)
scheme
- a connection scheme like "http", "https", or "wss"