Top Description Fields Constructors Methods
org.springframework.web.reactive.socket

public Class HandshakeInfo

extends Object
Class Inheritance
Imports
java.net.InetSocketAddress, .URI, java.security.Principal, java.util.Collections, .Map, reactor.core.publisher.Mono, org.springframework.http.HttpCookie, .HttpHeaders, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .MultiValueMap

Simple container of information related to the handshake request that started the WebSocketSession session.
Author
Rossen Stoyanchev
Since
5.0
See Also
WebSocketSession#getHandshakeInfo()

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>
private final MultiValueMap<String, HttpCookie>
private static final MultiValueMap<String, HttpCookie>
private final HttpHeaders
private final String
private final Mono<Principal>
private final String
private final InetSocketAddress
private final URI

Constructor Summary

AccessConstructor and Description
public
HandshakeInfo(URI
the endpoint URL
uri
,
HttpHeaders
request headers for server or response headers or client
headers
,
Mono<Principal>
the principal for the session
principal
,
String
the negotiated sub-protocol (may be null)
protocol
)

Constructor with basic information about the handshake.

public
HandshakeInfo(URI
the endpoint URL
uri
,
HttpHeaders
server request headers
headers
,
Mono<Principal>
the principal for the session
principal
,
String
the negotiated sub-protocol (may be null)
protocol
,
InetSocketAddress
the remote address of the client
remoteAddress
,
Map<String, Object>
initial attributes for the WebSocket session
attributes
,
String
the log prefix for the handshake request.
logPrefix
)

Constructor targeting server-side use with extra information such as the remote address, attributes, and a log prefix.

public
HandshakeInfo(URI
the endpoint URL
uri
,
HttpHeaders
server request headers
headers
,
MultiValueMap<String, HttpCookie>
server request cookies
cookies
,
Mono<Principal>
the principal for the session
principal
,
String
the negotiated sub-protocol (may be null)
protocol
,
InetSocketAddress
the remote address of the client
remoteAddress
,
Map<String, Object>
initial attributes for the WebSocket session
attributes
,
String
the log prefix for the handshake request.
logPrefix
)

Constructor targeting server-side use with extra information such as the cookies, remote address, attributes, and a log prefix.

Method Summary

Modifier and TypeMethod and Description
public Map<String, Object>
getAttributes()

Attributes extracted from the handshake request to add to the session.

public MultiValueMap<String, HttpCookie>
getCookies()

For a server session this returns the server request cookies from the handshake request.

public HttpHeaders
getHeaders()

Return the HTTP headers from the handshake request, either server request headers for a server session or the client response headers for a client session.

public String

Returns:

a log prefix, or null if not specified
getLogPrefix
()

A log prefix used in the handshake to correlate log messages, if any.

public Mono<Principal>
getPrincipal()

Return the principal associated with the handshake request, if any.

public InetSocketAddress
getRemoteAddress()

For a server session this is the remote address where the handshake request came from.

public String
getSubProtocol()

The sub-protocol negotiated at handshake time, or null if none.

public URI
getUri()

Return the URL for the WebSocket endpoint.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attributesback to summary
private final Map<String, Object> attributes
cookiesback to summary
private final MultiValueMap<String, HttpCookie> cookies
EMPTY_COOKIESback to summary
private static final MultiValueMap<String, HttpCookie> EMPTY_COOKIES
headersback to summary
private final HttpHeaders headers
logPrefixback to summary
private final String logPrefix
Annotations
@Nullable
principalMonoback to summary
private final Mono<Principal> principalMono
protocolback to summary
private final String protocol
Annotations
@Nullable
remoteAddressback to summary
private final InetSocketAddress remoteAddress
Annotations
@Nullable
uriback to summary
private final URI uri

Constructor Detail

HandshakeInfoback to summary
public HandshakeInfo(URI uri, HttpHeaders headers, Mono<Principal> principal, String protocol)

Constructor with basic information about the handshake.

Parameters
uri:URI

the endpoint URL

headers:HttpHeaders

request headers for server or response headers or client

principal:Mono<Principal>

the principal for the session

protocol:String

the negotiated sub-protocol (may be null)

HandshakeInfoback to summary
public HandshakeInfo(URI uri, HttpHeaders headers, Mono<Principal> principal, String protocol, InetSocketAddress remoteAddress, Map<String, Object> attributes, String logPrefix)

Constructor targeting server-side use with extra information such as the remote address, attributes, and a log prefix.

Parameters
uri:URI

the endpoint URL

headers:HttpHeaders

server request headers

principal:Mono<Principal>

the principal for the session

protocol:String

the negotiated sub-protocol (may be null)

remoteAddress:InetSocketAddress

the remote address of the client

attributes:Map<String, Object>

initial attributes for the WebSocket session

logPrefix:String

the log prefix for the handshake request.

Annotations
@Deprecated
Since
5.1
HandshakeInfoback to summary
public HandshakeInfo(URI uri, HttpHeaders headers, MultiValueMap<String, HttpCookie> cookies, Mono<Principal> principal, String protocol, InetSocketAddress remoteAddress, Map<String, Object> attributes, String logPrefix)

Constructor targeting server-side use with extra information such as the cookies, remote address, attributes, and a log prefix.

Parameters
uri:URI

the endpoint URL

headers:HttpHeaders

server request headers

cookies:MultiValueMap<String, HttpCookie>

server request cookies

principal:Mono<Principal>

the principal for the session

protocol:String

the negotiated sub-protocol (may be null)

remoteAddress:InetSocketAddress

the remote address of the client

attributes:Map<String, Object>

initial attributes for the WebSocket session

logPrefix:String

the log prefix for the handshake request.

Since
5.3.5

Method Detail

getAttributesback to summary
public Map<String, Object> getAttributes()

Attributes extracted from the handshake request to add to the session.

Since
5.1
getCookiesback to summary
public MultiValueMap<String, HttpCookie> getCookies()

For a server session this returns the server request cookies from the handshake request. For a client session, it is an empty map.

Since
5.3.5
getHeadersback to summary
public HttpHeaders getHeaders()

Return the HTTP headers from the handshake request, either server request headers for a server session or the client response headers for a client session.

getLogPrefixback to summary
public String getLogPrefix()

A log prefix used in the handshake to correlate log messages, if any.

Returns:String

a log prefix, or null if not specified

Annotations
@Nullable
Since
5.1
getPrincipalback to summary
public Mono<Principal> getPrincipal()

Return the principal associated with the handshake request, if any.

getRemoteAddressback to summary
public InetSocketAddress getRemoteAddress()

For a server session this is the remote address where the handshake request came from. For a client session, it is null.

Annotations
@Nullable
Since
5.1
getSubProtocolback to summary
public String getSubProtocol()

The sub-protocol negotiated at handshake time, or null if none.

Annotations
@Nullable
See Also
https://tools.ietf.org/html/rfc6455#section-1.9
getUriback to summary
public URI getUri()

Return the URL for the WebSocket endpoint.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override