Top Description Fields Constructors Methods
io.netty5.handler.codec.http.websocketx

public Class WebSocketClientHandshaker13

extends WebSocketClientHandshaker
Class Inheritance
Imports
io.netty5.buffer.BufferAllocator, io.netty5.handler.codec.http.DefaultFullHttpRequest, .FullHttpRequest, .FullHttpResponse, .HttpHeaderNames, .HttpHeaderValues, .HttpMethod, .HttpResponseStatus, .HttpVersion, io.netty5.handler.codec.http.headers.HttpHeaders, io.netty5.util.AsciiString, io.netty5.util.internal.StringUtil, java.net.URI

Performs client side opening and closing handshakes for web socket specification version websocketprotocol-v13

Field Summary

Modifier and TypeField and Description
private final boolean
private final boolean
private final boolean
private volatile String
Inherited from io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker:
customHeadersDEFAULT_FORCE_CLOSE_TIMEOUT_MILLIS

Constructor Summary

AccessConstructor and Description
public
WebSocketClientHandshaker13(URI
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
String
Sub protocol request sent to the server.
subprotocol
,
boolean
Allow extensions to be used in the reserved bits of the web socket frame
allowExtensions
,
HttpHeaders
Map of custom headers to add to the client request
customHeaders
,
int
Maximum length of a frame's payload
maxFramePayloadLength
)

Creates a new instance.

public
WebSocketClientHandshaker13(URI
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
String
Sub protocol request sent to the server.
subprotocol
,
boolean
Allow extensions to be used in the reserved bits of the web socket frame
allowExtensions
,
HttpHeaders
Map of custom headers to add to the client request
customHeaders
,
int
Maximum length of a frame's payload
maxFramePayloadLength
,
boolean
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.
performMasking
,
boolean
When set to true, frames which are not masked properly according to the standard will still be accepted.
allowMaskMismatch
)

Creates a new instance.

public
WebSocketClientHandshaker13(URI
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
String
Sub protocol request sent to the server.
subprotocol
,
boolean
Allow extensions to be used in the reserved bits of the web socket frame
allowExtensions
,
HttpHeaders
Map of custom headers to add to the client request
customHeaders
,
int
Maximum length of a frame's payload
maxFramePayloadLength
,
boolean
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.
performMasking
,
boolean
When set to true, frames which are not masked properly according to the standard will still be accepted
allowMaskMismatch
,
long
Close the connection if it was not closed by the server after timeout specified.
forceCloseTimeoutMillis
)

Creates a new instance.

pack-priv
WebSocketClientHandshaker13(URI
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
String
Sub protocol request sent to the server.
subprotocol
,
boolean
Allow extensions to be used in the reserved bits of the web socket frame
allowExtensions
,
HttpHeaders
Map of custom headers to add to the client request
customHeaders
,
int
Maximum length of a frame's payload
maxFramePayloadLength
,
boolean
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.
performMasking
,
boolean
When set to true, frames which are not masked properly according to the standard will still be accepted
allowMaskMismatch
,
long
Close the connection if it was not closed by the server after timeout specified.
forceCloseTimeoutMillis
,
boolean
Use an absolute url for the Upgrade request, typically when connecting through an HTTP proxy over clear HTTP
absoluteUpgradeUrl
)

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
private static String
createNonce()

Creates a nonce consisting of a randomly selected 16-byte value that has been base64-encoded.

protected FullHttpRequest
newHandshakeRequest(BufferAllocator allocator)

Implements abstract io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.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-Protocol: chat, superchat
Sec-WebSocket-Version: 13
protected WebSocketFrameDecoder
newWebsocketDecoder()

Implements abstract io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.newWebsocketDecoder.

Returns the decoder to use after handshake is complete.
protected WebSocketFrameEncoder
newWebSocketEncoder()

Implements abstract io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.newWebSocketEncoder.

Returns the encoder to use after the handshake is complete.
public WebSocketClientHandshaker13
setForceCloseTimeoutMillis(long
Close the connection if it was not closed by the server after timeout specified
forceCloseTimeoutMillis
)

Overrides io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.setForceCloseTimeoutMillis.

Sets timeout to close the connection if it was not closed by the server.
protected void
verify(FullHttpResponse
HTTP response returned from the server for the request sent by beginOpeningHandshake00().
response
)

Implements abstract io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.verify.

Process server response:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: chat
Inherited from io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker:
actualSubprotocolclosecloseexpectedSubprotocolfinishHandshakeforceCloseTimeoutMillishandshakeisForceCloseCompleteisHandshakeCompletemaxFramePayloadLengthprocessHandshakeupgradeUrluriversionwebsocketHostValue

Field Detail

allowExtensionsback to summary
private final boolean allowExtensions
allowMaskMismatchback to summary
private final boolean allowMaskMismatch
performMaskingback to summary
private final boolean performMasking
sentNonceback to summary
private volatile String sentNonce

Constructor Detail

WebSocketClientHandshaker13back to summary
public WebSocketClientHandshaker13(URI webSocketURL, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength)

Creates a new instance.

Parameters
webSocketURL:URI

URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.

subprotocol:String

Sub protocol request sent to the server.

allowExtensions:boolean

Allow extensions to be used in the reserved bits of the web socket frame

customHeaders:HttpHeaders

Map of custom headers to add to the client request

maxFramePayloadLength:int

Maximum length of a frame's payload

WebSocketClientHandshaker13back to summary
public WebSocketClientHandshaker13(URI webSocketURL, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch)

Creates a new instance.

Parameters
webSocketURL:URI

URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.

subprotocol:String

Sub protocol request sent to the server.

allowExtensions:boolean

Allow extensions to be used in the reserved bits of the web socket frame

customHeaders:HttpHeaders

Map of custom headers to add to the client request

maxFramePayloadLength:int

Maximum length of a frame's payload

performMasking:boolean

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:boolean

When set to true, frames which are not masked properly according to the standard will still be accepted.

WebSocketClientHandshaker13back to summary
public WebSocketClientHandshaker13(URI webSocketURL, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, long forceCloseTimeoutMillis)

Creates a new instance.

Parameters
webSocketURL:URI

URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.

subprotocol:String

Sub protocol request sent to the server.

allowExtensions:boolean

Allow extensions to be used in the reserved bits of the web socket frame

customHeaders:HttpHeaders

Map of custom headers to add to the client request

maxFramePayloadLength:int

Maximum length of a frame's payload

performMasking:boolean

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:boolean

When set to true, frames which are not masked properly according to the standard will still be accepted

forceCloseTimeoutMillis:long

Close the connection if it was not closed by the server after timeout specified.

WebSocketClientHandshaker13back to summary
pack-priv WebSocketClientHandshaker13(URI webSocketURL, String subprotocol, boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength, boolean performMasking, boolean allowMaskMismatch, long forceCloseTimeoutMillis, boolean absoluteUpgradeUrl)

Creates a new instance.

Parameters
webSocketURL:URI

URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.

subprotocol:String

Sub protocol request sent to the server.

allowExtensions:boolean

Allow extensions to be used in the reserved bits of the web socket frame

customHeaders:HttpHeaders

Map of custom headers to add to the client request

maxFramePayloadLength:int

Maximum length of a frame's payload

performMasking:boolean

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:boolean

When set to true, frames which are not masked properly according to the standard will still be accepted

forceCloseTimeoutMillis:long

Close the connection if it was not closed by the server after timeout specified.

absoluteUpgradeUrl:boolean

Use an absolute url for the Upgrade request, typically when connecting through an HTTP proxy over clear HTTP

Method Detail

createNonceback to summary
private static String createNonce()

Creates a nonce consisting of a randomly selected 16-byte value that has been base64-encoded.

newHandshakeRequestback to summary
protected FullHttpRequest newHandshakeRequest(BufferAllocator allocator)

Implements abstract io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.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-Protocol: chat, superchat
Sec-WebSocket-Version: 13
Annotations
@Override
newWebsocketDecoderback to summary
protected WebSocketFrameDecoder newWebsocketDecoder()

Implements abstract io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.newWebsocketDecoder.

Doc from io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.newWebsocketDecoder.

Returns the decoder to use after handshake is complete.

Annotations
@Override
newWebSocketEncoderback to summary
protected WebSocketFrameEncoder newWebSocketEncoder()

Implements abstract io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.newWebSocketEncoder.

Doc from io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.newWebSocketEncoder.

Returns the encoder to use after the handshake is complete.

Annotations
@Override
setForceCloseTimeoutMillisback to summary
public WebSocketClientHandshaker13 setForceCloseTimeoutMillis(long forceCloseTimeoutMillis)

Overrides io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.setForceCloseTimeoutMillis.

Doc from io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.setForceCloseTimeoutMillis.

Sets timeout to close the connection if it was not closed by the server.

Parameters
forceCloseTimeoutMillis:long

Close the connection if it was not closed by the server after timeout specified

Annotations
@Override
verifyback to summary
protected void verify(FullHttpResponse response)

Implements abstract io.netty5.handler.codec.http.websocketx.WebSocketClientHandshaker.verify.

Process server response:

HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
Sec-WebSocket-Protocol: chat
Parameters
response:FullHttpResponse

HTTP response returned from the server for the request sent by beginOpeningHandshake00().

Annotations
@Override
Exceptions
WebSocketHandshakeException:
if handshake response is invalid.