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

public Class WebSocketClientHandshaker07

extends WebSocketClientHandshaker
Class Inheritance
Imports
io.netty.buffer.Unpooled, io.netty.handler.codec.http.DefaultFullHttpRequest, .FullHttpRequest, .FullHttpResponse, .HttpHeaderNames, .HttpHeaderValues, .HttpHeaders, .HttpMethod, .HttpResponseStatus, .HttpVersion, io.netty.util.CharsetUtil, io.netty.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.net.URI

Performs client side opening and closing handshakes for web socket specification version draft-ietf-hybi-thewebsocketprotocol- 10

Field Summary

Modifier and TypeField and Description
private final boolean
private final boolean
private String
private static final InternalLogger
public static final String
private final boolean
Inherited from io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker:
customHeadersDEFAULT_FORCE_CLOSE_TIMEOUT_MILLISgenerateOriginHeader

Constructor Summary

AccessConstructor and Description
public
WebSocketClientHandshaker07(URI
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
WebSocketVersion
Version of web socket specification to use to connect to the server
version
,
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
WebSocketClientHandshaker07(URI
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
WebSocketVersion
Version of web socket specification to use to connect to the server
version
,
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
WebSocketClientHandshaker07(URI
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
WebSocketVersion
Version of web socket specification to use to connect to the server
version
,
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
WebSocketClientHandshaker07(URI
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
WebSocketVersion
Version of web socket specification to use to connect to the server
version
,
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.

pack-priv
WebSocketClientHandshaker07(URI
URL for web socket communications. e.g "ws://myhost.com/mypath". Subsequent web socket frames will be sent to this URL.
webSocketURL
,
WebSocketVersion
Version of web socket specification to use to connect to the server
version
,
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
,
boolean
Allows to generate a `Sec-WebSocket-Origin` header value for handshake request according to the given webSocketURL
generateOriginHeader
)

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
protected FullHttpRequest
newHandshakeRequest()

Implements abstract io.netty.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-Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 7
protected WebSocketFrameDecoder
newWebsocketDecoder()

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

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

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

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

Overrides io.netty.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.netty.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.netty.handler.codec.http.websocketx.WebSocketClientHandshaker:
actualSubprotocolclosecloseclosecloseexpectedSubprotocolfinishHandshakeforceCloseTimeoutMillishandshakehandshakeisForceCloseCompleteisHandshakeCompletemaxFramePayloadLengthprocessHandshakeprocessHandshakeupgradeUrluriversionwebsocketHostValuewebsocketOriginValue

Field Detail

allowExtensionsback to summary
private final boolean allowExtensions
allowMaskMismatchback to summary
private final boolean allowMaskMismatch
expectedChallengeResponseStringback to summary
private String expectedChallengeResponseString
loggerback to summary
private static final InternalLogger logger
MAGIC_GUIDback to summary
public static final String MAGIC_GUID
performMaskingback to summary
private final boolean performMasking

Constructor Detail

WebSocketClientHandshaker07back to summary
public WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, 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.

version:WebSocketVersion

Version of web socket specification to use to connect to the server

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

WebSocketClientHandshaker07back to summary
public WebSocketClientHandshaker07(URI webSocketURL, WebSocketVersion version, 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.

version:WebSocketVersion

Version of web socket specification to use to connect to the server

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.

WebSocketClientHandshaker07back to summary
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:URI

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

version:WebSocketVersion

Version of web socket specification to use to connect to the server

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.

WebSocketClientHandshaker07back to summary
pack-priv 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:URI

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

version:WebSocketVersion

Version of web socket specification to use to connect to the server

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

WebSocketClientHandshaker07back to summary
pack-priv 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:URI

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

version:WebSocketVersion

Version of web socket specification to use to connect to the server

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

generateOriginHeader:boolean

Allows to generate a `Sec-WebSocket-Origin` header value for handshake request according to the given webSocketURL

Method Detail

newHandshakeRequestback to summary
protected FullHttpRequest newHandshakeRequest()

Implements abstract io.netty.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-Origin: http://example.com
Sec-WebSocket-Protocol: chat, superchat
Sec-WebSocket-Version: 7
Annotations
@Override
newWebsocketDecoderback to summary
protected WebSocketFrameDecoder newWebsocketDecoder()

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

Doc from io.netty.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.netty.handler.codec.http.websocketx.WebSocketClientHandshaker.newWebSocketEncoder.

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

Returns the encoder to use after the handshake is complete.

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

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

Doc from io.netty.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.netty.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