Class WebSocketClientHandshaker07
java.lang.Object
io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker
io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker07
Performs client side opening and closing handshakes for web socket specification version draft-ietf-hybi-thewebsocketprotocol- 10
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final boolean
private String
private static final InternalLogger
static final String
private final boolean
Fields inherited from class io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker
customHeaders, DEFAULT_FORCE_CLOSE_TIMEOUT_MILLIS, generateOriginHeader
-
Constructor Summary
ConstructorsConstructorDescriptionWebSocketClientHandshaker07
(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength) Creates a new instance.WebSocketClientHandshaker07
(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch) Creates a new instance.WebSocketClientHandshaker07
(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, long forceCloseTimeoutMillis) Creates a new instance.WebSocketClientHandshaker07
(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, long forceCloseTimeoutMillis, boolean absoluteUpgradeUrl) Creates a new instance.WebSocketClientHandshaker07
(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, long forceCloseTimeoutMillis, boolean absoluteUpgradeUrl, boolean generateOriginHeader) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected FullHttpRequest
/**protected WebSocketFrameDecoder
Returns the decoder to use after handshake is complete.protected WebSocketFrameEncoder
Returns the encoder to use after the handshake is complete.setForceCloseTimeoutMillis
(long forceCloseTimeoutMillis) Sets timeout to close the connection if it was not closed by the server.protected void
verify
(FullHttpResponse response) Process server response:Methods inherited from class io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker
actualSubprotocol, close, close, close, close, expectedSubprotocol, finishHandshake, forceCloseTimeoutMillis, handshake, handshake, isForceCloseComplete, isHandshakeComplete, maxFramePayloadLength, processHandshake, processHandshake, upgradeUrl, uri, version, websocketHostValue, websocketOriginValue
-
Field Details
-
logger
-
MAGIC_GUID
- See Also:
-
expectedChallengeResponseString
-
allowExtensions
private final boolean allowExtensions -
performMasking
private final boolean performMasking -
allowMaskMismatch
private final boolean allowMaskMismatch
-
-
Constructor Details
-
WebSocketClientHandshaker07
public WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength) Creates a new instance.- Parameters:
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.version
- Version of web socket specification to use to connect to the serversubprotocol
- Sub protocol request sent to the server.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket framecustomHeaders
- Map of custom headers to add to the client requestmaxFramePayloadLength
- Maximum length of a frame's payload
-
WebSocketClientHandshaker07
public WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch) Creates a new instance.- Parameters:
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.version
- Version of web socket specification to use to connect to the serversubprotocol
- Sub protocol request sent to the server.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket framecustomHeaders
- Map of custom headers to add to the client requestmaxFramePayloadLength
- Maximum length of a frame's payloadperformMasking
- Whether to mask all written websocket frames. This must be set to true in order to be fully compatible with the websocket specifications. Client applications that communicate with a non-standard server which doesn't require masking might set this to false to achieve a higher performance.allowMaskMismatch
- When set to true, frames which are not masked properly according to the standard will still be accepted.
-
WebSocketClientHandshaker07
public WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, long forceCloseTimeoutMillis) Creates a new instance.- Parameters:
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.version
- Version of web socket specification to use to connect to the serversubprotocol
- Sub protocol request sent to the server.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket framecustomHeaders
- Map of custom headers to add to the client requestmaxFramePayloadLength
- Maximum length of a frame's payloadperformMasking
- Whether to mask all written websocket frames. This must be set to true in order to be fully compatible with the websocket specifications. Client applications that communicate with a non-standard server which doesn't require masking might set this to false to achieve a higher performance.allowMaskMismatch
- When set to true, frames which are not masked properly according to the standard will still be acceptedforceCloseTimeoutMillis
- Close the connection if it was not closed by the server after timeout specified.
-
WebSocketClientHandshaker07
WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, long forceCloseTimeoutMillis, boolean absoluteUpgradeUrl) Creates a new instance.- Parameters:
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.version
- Version of web socket specification to use to connect to the serversubprotocol
- Sub protocol request sent to the server.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket framecustomHeaders
- Map of custom headers to add to the client requestmaxFramePayloadLength
- Maximum length of a frame's payloadperformMasking
- Whether to mask all written websocket frames. This must be set to true in order to be fully compatible with the websocket specifications. Client applications that communicate with a non-standard server which doesn't require masking might set this to false to achieve a higher performance.allowMaskMismatch
- When set to true, frames which are not masked properly according to the standard will still be acceptedforceCloseTimeoutMillis
- Close the connection if it was not closed by the server after timeout specified.absoluteUpgradeUrl
- Use an absolute url for the Upgrade request, typically when connecting through an HTTP proxy over clear HTTP
-
WebSocketClientHandshaker07
WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, long forceCloseTimeoutMillis, boolean absoluteUpgradeUrl, boolean generateOriginHeader) Creates a new instance.- Parameters:
webSocketURL
- URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.version
- Version of web socket specification to use to connect to the serversubprotocol
- Sub protocol request sent to the server.allowExtensions
- Allow extensions to be used in the reserved bits of the web socket framecustomHeaders
- Map of custom headers to add to the client requestmaxFramePayloadLength
- Maximum length of a frame's payloadperformMasking
- Whether to mask all written websocket frames. This must be set to true in order to be fully compatible with the websocket specifications. Client applications that communicate with a non-standard server which doesn't require masking might set this to false to achieve a higher performance.allowMaskMismatch
- When set to true, frames which are not masked properly according to the standard will still be acceptedforceCloseTimeoutMillis
- Close the connection if it was not closed by the server after timeout specified.absoluteUpgradeUrl
- Use an absolute url for the Upgrade request, typically when connecting through an HTTP proxy over clear HTTPgenerateOriginHeader
- Allows to generate a `Sec-WebSocket-Origin` header value for handshake request according to the given webSocketURL
-
-
Method Details
-
newHandshakeRequest
/**Sends the opening request to the server:
GET /chat HTTP/1.1 Host: server.example.com Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Protocol: chat, superchat Sec-WebSocket-Version: 7
- Specified by:
newHandshakeRequest
in classWebSocketClientHandshaker
-
verify
Process server response:
HTTP/1.1 101 Switching Protocols Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= Sec-WebSocket-Protocol: chat
- Specified by:
verify
in classWebSocketClientHandshaker
- Parameters:
response
- HTTP response returned from the server for the request sent by beginOpeningHandshake00().- Throws:
WebSocketHandshakeException
-
newWebsocketDecoder
Description copied from class:WebSocketClientHandshaker
Returns the decoder to use after handshake is complete.- Specified by:
newWebsocketDecoder
in classWebSocketClientHandshaker
-
newWebSocketEncoder
Description copied from class:WebSocketClientHandshaker
Returns the encoder to use after the handshake is complete.- Specified by:
newWebSocketEncoder
in classWebSocketClientHandshaker
-
setForceCloseTimeoutMillis
Description copied from class:WebSocketClientHandshaker
Sets timeout to close the connection if it was not closed by the server.- Overrides:
setForceCloseTimeoutMillis
in classWebSocketClientHandshaker
- Parameters:
forceCloseTimeoutMillis
- Close the connection if it was not closed by the server after timeout specified
-