Top Description Methods
org.springframework.web.socket.server

public Interface HandshakeInterceptor

Known Direct Implementers
org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor, org.springframework.web.socket.server.support.OriginHandshakeInterceptor
Imports
java.util.Map, org.springframework.http.server.ServerHttpRequest, .ServerHttpResponse, org.springframework.lang.Nullable, org.springframework.web.socket.WebSocketHandler

Interceptor for WebSocket handshake requests. Can be used to inspect the handshake request and response as well as to pass attributes to the target WebSocketHandler.
Author
Rossen Stoyanchev
Since
4.0
See Also
org.springframework.web.socket.server.support.WebSocketHttpRequestHandler, org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService

Method Summary

Modifier and TypeMethod and Description
public void
afterHandshake(ServerHttpRequest
the current request
request
,
ServerHttpResponse
the current response
response
,
WebSocketHandler
the target WebSocket handler
wsHandler
,
Exception
an exception raised during the handshake, or null if none
exception
)

Invoked after the handshake is done.

public boolean

Returns:

whether to proceed with the handshake (true) or abort (false)
beforeHandshake
(ServerHttpRequest
the current request
request
,
ServerHttpResponse
the current response
response
,
WebSocketHandler
the target WebSocket handler
wsHandler
,
Map<String, Object>
the attributes from the HTTP handshake to associate with the WebSocket session; the provided attributes are copied, the original map is not used.
attributes
)

Invoked before the handshake is processed.

Method Detail

afterHandshakeback to summary
public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception)

Invoked after the handshake is done. The response status and headers indicate the results of the handshake, i.e. whether it was successful or not.

Parameters
request:ServerHttpRequest

the current request

response:ServerHttpResponse

the current response

wsHandler:WebSocketHandler

the target WebSocket handler

exception:Exception

an exception raised during the handshake, or null if none

beforeHandshakeback to summary
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception

Invoked before the handshake is processed.

Parameters
request:ServerHttpRequest

the current request

response:ServerHttpResponse

the current response

wsHandler:WebSocketHandler

the target WebSocket handler

attributes:Map<String, Object>

the attributes from the HTTP handshake to associate with the WebSocket session; the provided attributes are copied, the original map is not used.

Returns:boolean

whether to proceed with the handshake (true) or abort (false)