org.jboss.aerogear.io.netty.handler.codec.sockjs.transport
Class WebSocketHAProxyHandshaker
java.lang.Object
io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker
io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker00
org.jboss.aerogear.io.netty.handler.codec.sockjs.transport.WebSocketHAProxyHandshaker
public class WebSocketHAProxyHandshaker
- extends io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker00
An extension of WebSocketServerHandshaker00 which handles Hixie76
upgrade requests that plays nicely with HAProxy.
When HAProxy sends an WebSocket Hixie 76 upgrade reqeust will first send the request headers,
after receiveing the response, it will then send the nouce.
This class will extract the 'SEC_WEBSOCKET_KEY1' and 'SEC_WEBSOCKET_KEY2' from the first request
and later use it for the actual handshake.
Note that currently this does not work as desired with unless the HTTP request header 'Content-Lenght'
has been set. Netty's HttpObjectDecoder uses
HttpHeaders.getContentLength(HttpMessage, long) which will set the lenght
of Hixie 76 request to '8'. But there will be no body in the first request and therefor the message will be
dropped.
| Fields inherited from class io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker |
SUB_PROTOCOL_WILDCARD |
|
Method Summary |
void |
addWsCodec(io.netty.channel.ChannelFuture future)
|
protected io.netty.buffer.ByteBuf |
calculateLastKey(io.netty.buffer.ByteBuf content)
|
io.netty.channel.ChannelFuture |
handshake(io.netty.channel.Channel channel,
io.netty.handler.codec.http.FullHttpRequest req)
|
static boolean |
isHAProxyReqeust(io.netty.handler.codec.http.FullHttpRequest request)
A HAProxy request is a WebSocket Upgrade request with out a 'Sec-WebSocket-Version' and
does not have the final handshake key in the body of the request. |
protected io.netty.handler.codec.http.FullHttpResponse |
newHandshakeResponse(io.netty.handler.codec.http.FullHttpRequest req,
io.netty.handler.codec.http.HttpHeaders headers)
|
| Methods inherited from class io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker00 |
close, newWebsocketDecoder, newWebSocketEncoder |
| Methods inherited from class io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker |
close, handshake, maxFramePayloadLength, selectedSubprotocol, selectSubprotocol, subprotocols, uri, version |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WebSocketHAProxyHandshaker
public WebSocketHAProxyHandshaker(String webSocketURL,
String subprotocols,
int maxFramePayloadLength)
newHandshakeResponse
protected io.netty.handler.codec.http.FullHttpResponse newHandshakeResponse(io.netty.handler.codec.http.FullHttpRequest req,
io.netty.handler.codec.http.HttpHeaders headers)
- Overrides:
newHandshakeResponse in class io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker00
calculateLastKey
protected io.netty.buffer.ByteBuf calculateLastKey(io.netty.buffer.ByteBuf content)
handshake
public io.netty.channel.ChannelFuture handshake(io.netty.channel.Channel channel,
io.netty.handler.codec.http.FullHttpRequest req)
- Overrides:
handshake in class io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker
addWsCodec
public void addWsCodec(io.netty.channel.ChannelFuture future)
isHAProxyReqeust
public static boolean isHAProxyReqeust(io.netty.handler.codec.http.FullHttpRequest request)
- A HAProxy request is a WebSocket Upgrade request with out a 'Sec-WebSocket-Version' and
does not have the final handshake key in the body of the request.
Copyright © 2014 JBoss by Red Hat. All Rights Reserved.