org.springframework.web.reactive.socket

## 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:
  `WebSocketSession.getHandshakeInfo()`

### Constructor Summary

Constructors
Constructor and Description
`HandshakeInfo(URI uri, org.springframework.http.HttpHeaders headers, reactor.core.publisher.Mono<Principal> principal, String protocol)` Constructor with basic information about the handshake.
`HandshakeInfo(URI uri, org.springframework.http.HttpHeaders headers, reactor.core.publisher.Mono<Principal> principal, String protocol, InetSocketAddress remoteAddress, Map<String,Object> attributes, String logPrefix)` Constructor targetting server-side use with extra information about the handshake, the remote address, and a pre-existing log prefix for correlation.

### Method Summary

All Methods Instance Methods Concrete Methods
`Map<String,Object>` `getAttributes()` Attributes extracted from the handshake request to be added to the WebSocket session.
`org.springframework.http.HttpHeaders` `getHeaders()` Return the handshake HTTP headers.
`String` `getLogPrefix()` A log prefix used in the handshake to correlate log messages, if any.
`reactor.core.publisher.Mono<Principal>` `getPrincipal()` Return the principal associated with the handshake HTTP request.
`InetSocketAddress` `getRemoteAddress()` For a server-side session this is the remote address where the handshake request came from.
`String` `getSubProtocol()` The sub-protocol negotiated at handshake time, or `null` if none.
`URI` `getUri()` Return the URL for the WebSocket endpoint.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### HandshakeInfo

    public HandshakeInfo(URI uri,
                         org.springframework.http.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

    public HandshakeInfo(URI uri,
                         org.springframework.http.HttpHeaders headers,
                         reactor.core.publisher.Mono<Principal> principal,
                         @Nullable
                         String protocol,
                         @Nullable
                         InetSocketAddress remoteAddress,
                         Map<String,Object> attributes,
                         @Nullable
                         String logPrefix)

Constructor targetting server-side use with extra information about the handshake, the remote address, and a pre-existing log prefix for correlation.

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`)
  `remoteAddress` - the remote address where the handshake came from
  `attributes` - initial attributes to use for the WebSocket session
  `logPrefix` - log prefix used during the handshake for correlating log messages, if any.
Since:
  5.1

### Method Detail

#### getUri

    public URI getUri()

Return the URL for the WebSocket endpoint.

#### getHeaders

    public org.springframework.http.HttpHeaders getHeaders()

Return the handshake HTTP headers. Those are the request headers for a server session and the response headers for a client session.

#### getPrincipal

    public reactor.core.publisher.Mono<Principal> getPrincipal()

Return the principal associated with the handshake HTTP request.

#### getSubProtocol

    @Nullable
    public String getSubProtocol()

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

See Also:
  https://tools.ietf.org/html/rfc6455#section-1.9

#### getRemoteAddress

    @Nullable
    public InetSocketAddress getRemoteAddress()

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

Since:
  5.1

#### getAttributes

    public Map<String,Object> getAttributes()

Attributes extracted from the handshake request to be added to the WebSocket 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`