Class HandshakeInfo

java.lang.Object
org.springframework.web.reactive.socket.HandshakeInfo

public class HandshakeInfo extends Object
Simple container of information related to the handshake request that started the WebSocketSession session.
Since:
5.0
Author:
Rossen Stoyanchev
See Also:
  • 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 URL
      headers - request headers for server or response headers or client
      principal - the principal for the session
      protocol - the negotiated sub-protocol (may be null)
    • 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)
      Constructor targeting server-side use with extra information such as the remote address, attributes, and a log prefix.
      Parameters:
      uri - the endpoint URL
      headers - server request headers
      principal - the principal for the session
      protocol - the negotiated sub-protocol (may be null)
      remoteAddress - the remote address of the client
      attributes - initial attributes for the WebSocket session
      logPrefix - 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 URL
      headers - server request headers
      cookies - server request cookies
      principal - the principal for the session
      protocol - the negotiated sub-protocol (may be null)
      remoteAddress - the remote address of the client
      attributes - initial attributes for the WebSocket session
      logPrefix - the log prefix for the handshake request.
      Since:
      5.3.5
  • Method Details

    • getUri

      public URI getUri()
      Return the URL for the WebSocket endpoint.
    • getHeaders

      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.
    • getCookies

      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
    • getPrincipal

      public reactor.core.publisher.Mono<Principal> getPrincipal()
      Return the principal associated with the handshake request, if any.
    • getSubProtocol

      @Nullable public String getSubProtocol()
      The sub-protocol negotiated at handshake time, or null if none.
      See Also:
    • getRemoteAddress

      @Nullable 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.
      Since:
      5.1
    • getAttributes

      public Map<String,Object> getAttributes()
      Attributes extracted from the handshake request to add to the session.
      Since:
      5.1
    • getLogPrefix

      @Nullable public String getLogPrefix()
      A log prefix used in the handshake to correlate log messages, if any.
      Returns:
      a log prefix, or null if not specified
      Since:
      5.1
    • toString

      public String toString()
      Overrides:
      toString in class Object