public class WebSocketHAProxyHandshaker
extends io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker00
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.| Constructor and Description |
|---|
WebSocketHAProxyHandshaker(String webSocketURL,
String subprotocols,
int maxFramePayloadLength) |
| Modifier and Type | Method and Description |
|---|---|
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) |
close, newWebsocketDecoder, newWebSocketEncoderprotected io.netty.handler.codec.http.FullHttpResponse newHandshakeResponse(io.netty.handler.codec.http.FullHttpRequest req,
io.netty.handler.codec.http.HttpHeaders headers)
newHandshakeResponse in class io.netty.handler.codec.http.websocketx.WebSocketServerHandshaker00protected io.netty.buffer.ByteBuf calculateLastKey(io.netty.buffer.ByteBuf content)
public io.netty.channel.ChannelFuture handshake(io.netty.channel.Channel channel,
io.netty.handler.codec.http.FullHttpRequest req)
handshake in class io.netty.handler.codec.http.websocketx.WebSocketServerHandshakerpublic void addWsCodec(io.netty.channel.ChannelFuture future)
public static boolean isHAProxyReqeust(io.netty.handler.codec.http.FullHttpRequest request)
Copyright © 2014 JBoss by Red Hat. All Rights Reserved.