// Set Content-Length to workaround some known defect.
// See also: http://www.ietf.org/mail-archive/web/hybi/current/msg02149.html
request.setHeader(Names.CONTENT_LENGTH, key3.length);
request.setContent(ChannelBuffers.copiedBuffer(key3));
final ChannelFuture handshakeFuture = new DefaultChannelFuture(channel, false);
ChannelFuture future = channel.write(request);
future.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) {
ChannelPipeline p = future.getChannel().getPipeline();
p.replace(HttpRequestEncoder.class, "ws-encoder", new WebSocket00FrameEncoder());
if (future.isSuccess()) {
handshakeFuture.setSuccess();
} else {
handshakeFuture.setFailure(future.getCause());
}
}
});
return handshakeFuture;