Package org.glassfish.tyrus.core
Class Handshake
- java.lang.Object
-
- org.glassfish.tyrus.core.Handshake
-
public final class Handshake extends java.lang.Object
Class responsible for performing and validating handshake.- Author:
- Justin Lee, Pavel Bucek
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Handshake
createClientHandshake(RequestContext webSocketRequest)
Client-side handshake.RequestContext
getRequest()
Client side only - get theUpgradeRequest
.UpgradeRequest
prepareRequest()
Client side only - compose theUpgradeRequest
and store it for further use.void
setExtensions(java.util.List<Extension> extensions)
Client side only - set the list of supported extensions.void
setSubProtocols(java.util.List<java.lang.String> subProtocols)
Client side only - set the list of supported subprotocols.static void
updateHostAndOrigin(UpgradeRequest upgradeRequest)
Client side only - Generate host and origin header and put them to the upgrade request headers.void
validateServerResponse(UpgradeResponse response)
Client side only - validate server response.
-
-
-
Method Detail
-
createClientHandshake
public static Handshake createClientHandshake(RequestContext webSocketRequest)
Client-side handshake.- Parameters:
webSocketRequest
- request representation to be modified for use as WebSocket handshake request.- Returns:
- handshake instance.
-
getRequest
public RequestContext getRequest()
Client side only - get theUpgradeRequest
.- Returns:
UpgradeRequest
created on this HandShake.
-
setSubProtocols
public void setSubProtocols(java.util.List<java.lang.String> subProtocols)
Client side only - set the list of supported subprotocols.- Parameters:
subProtocols
- list of supported subprotocol.
-
setExtensions
public void setExtensions(java.util.List<Extension> extensions)
Client side only - set the list of supported extensions.- Parameters:
extensions
- list of supported extensions.
-
prepareRequest
public UpgradeRequest prepareRequest()
Client side only - compose theUpgradeRequest
and store it for further use.- Returns:
- composed
UpgradeRequest
.
-
validateServerResponse
public void validateServerResponse(UpgradeResponse response) throws HandshakeException
Client side only - validate server response.- Parameters:
response
- response to be validated.- Throws:
HandshakeException
- when HTTP Status of received response is not 101 - Switching protocols.
-
updateHostAndOrigin
public static void updateHostAndOrigin(UpgradeRequest upgradeRequest)
Client side only - Generate host and origin header and put them to the upgrade request headers.- Parameters:
upgradeRequest
- upgrade request to be updated.
-
-