Performs client side opening and closing handshakes for web socket specification version draft-ietf-hybi-thewebsocketprotocol- 00
A very large portion of this code was taken from the Netty 3.2 HTTP example.
| Modifier and Type | Field and Description |
|---|---|
| private ByteBuf |
| Access | Constructor and Description |
|---|---|
| public | WebSocketClientHandshaker00(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, 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 with the specified destination WebSocket location and version to initiate. |
| public | WebSocketClientHandshaker00(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, HttpHeaders Map of custom headers to add to the client request customHeaders, int Maximum length of a frame's payload maxFramePayloadLength, long Close the connection if it was not closed by the server after timeout specified forceCloseTimeoutMillis)Creates a new instance with the specified destination WebSocket location and version to initiate. |
| pack-priv | WebSocketClientHandshaker00(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, HttpHeaders Map of custom headers to add to the client request customHeaders, int Maximum length of a frame's payload maxFramePayloadLength, 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 with the specified destination WebSocket location and version to initiate. |
| pack-priv | WebSocketClientHandshaker00(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, HttpHeaders Map of custom headers to add to the client request customHeaders, int Maximum length of a frame's payload maxFramePayloadLength, 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 the `Origin` header value for handshake request
according to the given webSocketURL generateOriginHeader)Creates a new instance with the specified destination WebSocket location and version to initiate. |
| Modifier and Type | Method and Description |
|---|---|
| private static String | |
| private static String | |
| protected FullHttpRequest | newHandshakeRequest()
Implements abstract io. Sends the opening request to the server: GET /demo HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: example.com Origin: http://example.com Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5 Sec-WebSocket-Key2: 12998 5 Y3 1 .P00 ^n:ds[4U |
| protected WebSocketFrameDecoder | newWebsocketDecoder()
Implements abstract io. |
| protected WebSocketFrameEncoder | newWebSocketEncoder()
Implements abstract io. |
| public WebSocketClientHandshaker00 | setForceCloseTimeoutMillis(long
Close the connection if it was not closed by the server after timeout specified forceCloseTimeoutMillis)Overrides io. |
| protected void | verify(FullHttpResponse
HTTP response returned from the server for the request sent by beginOpeningHandshake00(). response)Implements abstract io. Process server response: HTTP/1.1 101 WebSocket Protocol Handshake Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Location: ws://example.com/demo Sec-WebSocket-Protocol: sample 8jKS'y:G*Co,Wxa- |
| expectedChallengeResponseBytes | back to summary |
|---|---|
| private ByteBuf expectedChallengeResponseBytes | |
| WebSocketClientHandshaker00 | back to summary |
|---|---|
| public WebSocketClientHandshaker00(URI webSocketURL, WebSocketVersion version, String subprotocol, HttpHeaders customHeaders, int maxFramePayloadLength) Creates a new instance with the specified destination WebSocket location and version to initiate.
| |
| WebSocketClientHandshaker00 | back to summary |
|---|---|
| public WebSocketClientHandshaker00(URI webSocketURL, WebSocketVersion version, String subprotocol, HttpHeaders customHeaders, int maxFramePayloadLength, long forceCloseTimeoutMillis) Creates a new instance with the specified destination WebSocket location and version to initiate.
| |
| WebSocketClientHandshaker00 | back to summary |
|---|---|
| pack-priv WebSocketClientHandshaker00(URI webSocketURL, WebSocketVersion version, String subprotocol, HttpHeaders customHeaders, int maxFramePayloadLength, long forceCloseTimeoutMillis, boolean absoluteUpgradeUrl) Creates a new instance with the specified destination WebSocket location and version to initiate.
| |
| WebSocketClientHandshaker00 | back to summary |
|---|---|
| pack-priv WebSocketClientHandshaker00(URI webSocketURL, WebSocketVersion version, String subprotocol, HttpHeaders customHeaders, int maxFramePayloadLength, long forceCloseTimeoutMillis, boolean absoluteUpgradeUrl, boolean generateOriginHeader) Creates a new instance with the specified destination WebSocket location and version to initiate.
| |
| insertRandomCharacters | back to summary |
|---|---|
| private static String insertRandomCharacters(String key) | |
| insertSpaces | back to summary |
|---|---|
| private static String insertSpaces(String key, int spaces) | |
| newHandshakeRequest | back to summary |
|---|---|
| protected FullHttpRequest newHandshakeRequest() Implements abstract io. Sends the opening request to the server: GET /demo HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: example.com Origin: http://example.com Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5 Sec-WebSocket-Key2: 12998 5 Y3 1 .P00 ^n:ds[4U
| |
| newWebsocketDecoder | back to summary |
|---|---|
| protected WebSocketFrameDecoder newWebsocketDecoder() Implements abstract io. Doc from io. Returns the decoder to use after handshake is complete.
| |
| newWebSocketEncoder | back to summary |
|---|---|
| protected WebSocketFrameEncoder newWebSocketEncoder() Implements abstract io. Doc from io. Returns the encoder to use after the handshake is complete.
| |
| setForceCloseTimeoutMillis | back to summary |
|---|---|
| public WebSocketClientHandshaker00 setForceCloseTimeoutMillis(long forceCloseTimeoutMillis) Overrides io. Doc from io. Sets timeout to close the connection if it was not closed by the server.
| |
| verify | back to summary |
|---|---|
| protected void verify(FullHttpResponse response) Implements abstract io. Process server response: HTTP/1.1 101 WebSocket Protocol Handshake Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Location: ws://example.com/demo Sec-WebSocket-Protocol: sample 8jKS'y:G*Co,Wxa-
| |