Class HandshakeInfo
java.lang.Object
org.springframework.web.reactive.socket.HandshakeInfo
Simple container of information related to the handshake request that started
the
WebSocketSession session.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionHandshakeInfo(URI uri, HttpHeaders headers, MultiValueMap<String, HttpCookie> cookies, reactor.core.publisher.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.HandshakeInfo(URI uri, HttpHeaders headers, reactor.core.publisher.Mono<Principal> principal, String protocol) Constructor with basic information about the handshake.HandshakeInfo(URI uri, HttpHeaders headers, reactor.core.publisher.Mono<Principal> principal, String protocol, InetSocketAddress remoteAddress, Map<String, Object> attributes, String logPrefix) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionAttributes extracted from the handshake request to add to the session.For a server session this returns the server request cookies from the handshake request.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.A log prefix used in the handshake to correlate log messages, if any.reactor.core.publisher.Mono<Principal>Return the principal associated with the handshake request, if any.For a server session this is the remote address where the handshake request came from.The sub-protocol negotiated at handshake time, ornullif none.getUri()Return the URL for the WebSocket endpoint.toString()
-
Constructor Details
-
HandshakeInfo
public HandshakeInfo(URI uri, HttpHeaders headers, reactor.core.publisher.Mono<Principal> principal, @Nullable String protocol) Constructor with basic information about the handshake.- Parameters:
uri- the endpoint URLheaders- request headers for server or response headers or clientprincipal- the principal for the sessionprotocol- the negotiated sub-protocol (may benull)
-
HandshakeInfo
@Deprecated public HandshakeInfo(URI uri, HttpHeaders headers, reactor.core.publisher.Mono<Principal> principal, @Nullable String protocol, @Nullable InetSocketAddress remoteAddress, Map<String, Object> attributes, @Nullable String logPrefix) Deprecated.as of 5.3.5 in favor ofHandshakeInfo(URI, HttpHeaders, MultiValueMap, Mono, String, InetSocketAddress, Map, String)Constructor targeting server-side use with extra information such as the remote address, attributes, and a log prefix.- Parameters:
uri- the endpoint URLheaders- server request headersprincipal- the principal for the sessionprotocol- the negotiated sub-protocol (may benull)remoteAddress- the remote address of the clientattributes- initial attributes for the WebSocket sessionlogPrefix- the log prefix for the handshake request.- Since:
- 5.1
-
HandshakeInfo
public HandshakeInfo(URI uri, HttpHeaders headers, MultiValueMap<String, HttpCookie> cookies, reactor.core.publisher.Mono<Principal> principal, @Nullable String protocol, @Nullable InetSocketAddress remoteAddress, Map<String, Object> attributes, @Nullable String logPrefix) Constructor targeting server-side use with extra information such as the cookies, remote address, attributes, and a log prefix.- Parameters:
uri- the endpoint URLheaders- server request headerscookies- server request cookiesprincipal- the principal for the sessionprotocol- the negotiated sub-protocol (may benull)remoteAddress- the remote address of the clientattributes- initial attributes for the WebSocket sessionlogPrefix- the log prefix for the handshake request.- Since:
- 5.3.5
-
-
Method Details
-
getUri
Return the URL for the WebSocket endpoint. -
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. -
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
-
getPrincipal
Return the principal associated with the handshake request, if any. -
getSubProtocol
The sub-protocol negotiated at handshake time, ornullif none. -
getRemoteAddress
For a server session this is the remote address where the handshake request came from. For a client session, it isnull.- Since:
- 5.1
-
getAttributes
Attributes extracted from the handshake request to add to the session.- Since:
- 5.1
-
getLogPrefix
A log prefix used in the handshake to correlate log messages, if any.- Returns:
- a log prefix, or
nullif not specified - Since:
- 5.1
-
toString
-
HandshakeInfo(URI, HttpHeaders, MultiValueMap, Mono, String, InetSocketAddress, Map, String)