Top Description Fields Constructors Methods
reactor.netty.http.server

public final Class ConnectionInfo

extends Object
Class Inheritance
Imports
java.net.InetSocketAddress, .SocketAddress, java.util.function.BiFunction, io.netty.channel.Channel, io.netty.handler.codec.http.HttpHeaderNames, .HttpRequest, reactor.util.annotation.Nullable

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.

Authors
Brian Clozel, Andrey Shlykov
Since
0.8
See Also
rfc7239

Field Summary

Modifier and TypeField and Description
pack-priv static final String
pack-priv static final int
pack-priv static final int
pack-priv final SocketAddress
pack-priv final String
pack-priv final int
pack-priv final boolean
pack-priv final SocketAddress
pack-priv final String

Constructor Summary

AccessConstructor and Description
pack-priv
ConnectionInfo(SocketAddress hostAddress, SocketAddress remoteAddress, boolean secured)

pack-priv
ConnectionInfo(SocketAddress hostAddress, String hostName, int hostPort, SocketAddress remoteAddress, String scheme, boolean isInetAddress)

Method Summary

Modifier and TypeMethod and Description
pack-priv static ConnectionInfo
from(Channel channel, HttpRequest request, boolean secured, SocketAddress remoteAddress, BiFunction<ConnectionInfo, HttpRequest, ConnectionInfo> forwardedHeaderHandler)

public static int

Returns:

the default host port number based on scheme
getDefaultHostPort
(String
a connection scheme like "http", "https", or "wss"
scheme
)

Returns the default host port number based on scheme.

public InetSocketAddress

Returns:

the host address
getHostAddress
()

Return the host address of the connection.

public String

Returns:

the connection host name
getHostName
()

Returns the connection host name.

public int

Returns:

the connection host port
getHostPort
()

Returns the connection host port.

public InetSocketAddress

Returns:

the remote address
getRemoteAddress
()

Return the remote address of the connection.

public String

Returns:

the connection scheme
getScheme
()

Return the connection scheme.

public ConnectionInfo

Returns:

a new ConnectionInfo
withHostAddress
(InetSocketAddress
the host address
hostAddress
)

Return a new ConnectionInfo with the updated host address.

public ConnectionInfo

Returns:

a new ConnectionInfo
withHostAddress
(InetSocketAddress
the updated host address
hostAddress
,
String
the updated host name
hostName
,
int
the updated host port
hostPort
)

Return a new ConnectionInfo with updated host address, host name, and host port information.

public ConnectionInfo

Returns:

a new ConnectionInfo
withRemoteAddress
(InetSocketAddress
the remote address
remoteAddress
)

Return a new ConnectionInfo with the updated remote address.

public ConnectionInfo

Returns:

a new ConnectionInfo
withScheme
(String
the connection scheme
scheme
)

Return a new ConnectionInfo with the updated scheme.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_HOST_NAMEback to summary
pack-priv static final String DEFAULT_HOST_NAME
DEFAULT_HTTP_PORTback to summary
pack-priv static final int DEFAULT_HTTP_PORT
DEFAULT_HTTPS_PORTback to summary
pack-priv static final int DEFAULT_HTTPS_PORT
hostAddressback to summary
pack-priv final SocketAddress hostAddress
hostNameback to summary
pack-priv final String hostName
hostPortback to summary
pack-priv final int hostPort
isInetAddressback to summary
pack-priv final boolean isInetAddress
remoteAddressback to summary
pack-priv final SocketAddress remoteAddress
schemeback to summary
pack-priv final String scheme

Constructor Detail

ConnectionInfoback to summary
pack-priv ConnectionInfo(SocketAddress hostAddress, SocketAddress remoteAddress, boolean secured)
ConnectionInfoback to summary
pack-priv ConnectionInfo(SocketAddress hostAddress, String hostName, int hostPort, SocketAddress remoteAddress, String scheme, boolean isInetAddress)

Method Detail

fromback to summary
pack-priv static ConnectionInfo from(Channel channel, HttpRequest request, boolean secured, SocketAddress remoteAddress, BiFunction<ConnectionInfo, HttpRequest, ConnectionInfo> forwardedHeaderHandler)
getDefaultHostPortback to summary
public static int getDefaultHostPort(String scheme)

Returns the default host port number based on scheme.

Parameters
scheme:String

a connection scheme like "http", "https", or "wss"

Returns:int

the default host port number based on scheme

Since
1.0.32
getHostAddressback to summary
public InetSocketAddress getHostAddress()

Return the host address of the connection.

Returns:InetSocketAddress

the host address

Annotations
@Nullable
getHostNameback to summary
public String getHostName()

Returns the connection host name.

Returns:String

the connection host name

Since
1.0.32
getHostPortback to summary
public int getHostPort()

Returns the connection host port.

Returns:int

the connection host port

Since
1.0.32
getRemoteAddressback to summary
public InetSocketAddress getRemoteAddress()

Return the remote address of the connection.

Returns:InetSocketAddress

the remote address

Annotations
@Nullable
getSchemeback to summary
public String getScheme()

Return the connection scheme.

Returns:String

the connection scheme

withHostAddressback to summary
public ConnectionInfo withHostAddress(InetSocketAddress hostAddress)

Return a new ConnectionInfo with the updated host address.

Parameters
hostAddress:InetSocketAddress

the host address

Returns:ConnectionInfo

a new ConnectionInfo

withHostAddressback to summary
public ConnectionInfo withHostAddress(InetSocketAddress hostAddress, String hostName, int hostPort)

Return a new ConnectionInfo with updated host address, host name, and host port information.

Parameters
hostAddress:InetSocketAddress

the updated host address

hostName:String

the updated host name

hostPort:int

the updated host port

Returns:ConnectionInfo

a new ConnectionInfo

Since
1.0.32
withRemoteAddressback to summary
public ConnectionInfo withRemoteAddress(InetSocketAddress remoteAddress)

Return a new ConnectionInfo with the updated remote address.

Parameters
remoteAddress:InetSocketAddress

the remote address

Returns:ConnectionInfo

a new ConnectionInfo

withSchemeback to summary
public ConnectionInfo withScheme(String scheme)

Return a new ConnectionInfo with the updated scheme.

Parameters
scheme:String

the connection scheme

Returns:ConnectionInfo

a new ConnectionInfo