Class WebSocketServerHandshaker13
java.lang.Object
io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker
io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker13
Performs server side opening and closing handshakes for RFC 6455 (originally web socket specification draft-ietf-hybi-thewebsocketprotocol-17).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]static final java.lang.StringFields inherited from class WebSocketServerHandshaker
logger, SUB_PROTOCOL_WILDCARD -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketServerHandshaker13(boolean isSecure, java.lang.String host, java.lang.String path, java.lang.String subprotocols, WebSocketDecoderConfig decoderConfig) WebSocketServerHandshaker13(java.lang.String webSocketURL, java.lang.String subprotocols, boolean allowExtensions, int maxFramePayloadLength) Constructor specifying the destination web socket locationWebSocketServerHandshaker13(java.lang.String webSocketURL, java.lang.String subprotocols, boolean allowExtensions, int maxFramePayloadLength, boolean allowMaskMismatch) Constructor specifying the destination web socket locationWebSocketServerHandshaker13(java.lang.String webSocketURL, java.lang.String subprotocols, WebSocketDecoderConfig decoderConfig) Constructor specifying the destination web socket location -
Method Summary
Modifier and TypeMethodDescriptionprotected FullHttpResponsenewHandshakeResponse(FullHttpRequest req, HttpHeaders headers) Handle the web socket handshake for the web socket specification HyBi versions 13-17.protected WebSocketFrameDecoderReturns the decoder to use after handshake is complete.protected WebSocketFrameEncoderReturns the encoder to use after the handshake is complete.Methods inherited from class WebSocketServerHandshaker
close, close, close, close, decoderConfig, handshake, handshake, handshake, handshake, handshake, handshake, handshake, handshake, maxFramePayloadLength, selectedSubprotocol, selectSubprotocol, subprotocols, uri, versionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
WEBSOCKET_13_ACCEPT_GUID
public static final java.lang.String WEBSOCKET_13_ACCEPT_GUID- See Also:
-
GUID_BYTES
private static final byte[] GUID_BYTES
-
-
Constructor Details
-
WebSocketServerHandshaker13
public WebSocketServerHandshaker13(java.lang.String webSocketURL, java.lang.String subprotocols, boolean allowExtensions, int maxFramePayloadLength) Constructor specifying the destination web socket location- Parameters:
webSocketURL- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.subprotocols- CSV of supported protocolsallowExtensions- Allow extensions to be used in the reserved bits of the web socket framemaxFramePayloadLength- Maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.
-
WebSocketServerHandshaker13
public WebSocketServerHandshaker13(java.lang.String webSocketURL, java.lang.String subprotocols, boolean allowExtensions, int maxFramePayloadLength, boolean allowMaskMismatch) Constructor specifying the destination web socket location- Parameters:
webSocketURL- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.subprotocols- CSV of supported protocolsallowExtensions- Allow extensions to be used in the reserved bits of the web socket framemaxFramePayloadLength- Maximum allowable frame payload length. Setting this value to your application's requirement may reduce denial of service attacks using long data frames.allowMaskMismatch- When set to true, frames which are not masked properly according to the standard will still be accepted.
-
WebSocketServerHandshaker13
public WebSocketServerHandshaker13(java.lang.String webSocketURL, java.lang.String subprotocols, WebSocketDecoderConfig decoderConfig) Constructor specifying the destination web socket location- Parameters:
webSocketURL- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.subprotocols- CSV of supported protocolsdecoderConfig- Frames decoder configuration.
-
WebSocketServerHandshaker13
WebSocketServerHandshaker13(boolean isSecure, java.lang.String host, java.lang.String path, java.lang.String subprotocols, WebSocketDecoderConfig decoderConfig)
-
-
Method Details
-
newHandshakeResponse
Handle the web socket handshake for the web socket specification HyBi versions 13-17. Versions 13-17 share the same wire protocol.
Browser request to the server:
GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Origin: http://example.com Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 13
Server response:
HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat
- Specified by:
newHandshakeResponsein classWebSocketServerHandshaker
-
newWebsocketDecoder
Description copied from class:WebSocketServerHandshakerReturns the decoder to use after handshake is complete.- Specified by:
newWebsocketDecoderin classWebSocketServerHandshaker
-
newWebSocketEncoder
Description copied from class:WebSocketServerHandshakerReturns the encoder to use after the handshake is complete.- Specified by:
newWebSocketEncoderin classWebSocketServerHandshaker
-