use of io.vertx.core.net.impl.HAProxyMessageCompletionHandler in project vert.x by eclipse.
the class HttpServerWorker method handle.
@Override
public void handle(Channel ch) {
if (HAProxyMessageCompletionHandler.canUseProxyProtocol(options.isUseProxyProtocol())) {
IdleStateHandler idle;
io.netty.util.concurrent.Promise<Channel> p = ch.eventLoop().newPromise();
ch.pipeline().addLast(new HAProxyMessageDecoder());
if (options.getProxyProtocolTimeout() > 0) {
ch.pipeline().addLast("idle", idle = new IdleStateHandler(0, 0, options.getProxyProtocolTimeout(), options.getProxyProtocolTimeoutUnit()));
} else {
idle = null;
}
ch.pipeline().addLast(new HAProxyMessageCompletionHandler(p));
p.addListener((GenericFutureListener<Future<Channel>>) future -> {
if (future.isSuccess()) {
if (idle != null) {
ch.pipeline().remove(idle);
}
configurePipeline(future.getNow());
} else {
handleException(future.cause());
}
});
} else {
configurePipeline(ch);
}
}
Aggregations