/** * Setup the required handlers on pipeline using this method. * * @param pipeline */ public void addProxyProtocol(ChannelPipeline pipeline) { pipeline.addLast(NAME, this); if (withProxyProtocol) { pipeline.addBefore(NAME, OptionalHAProxyMessageDecoder.NAME, new OptionalHAProxyMessageDecoder()); } }
public void startReadTimeoutHandler(int readTimeout) { channel.pipeline().addBefore("originNettyLogger", READ_TIMEOUT_HANDLER_NAME, new ReadTimeoutHandler(readTimeout, TimeUnit.MILLISECONDS)); }
@Override protected void addCodec(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); String name = ctx.name(); p.addBefore(name, null, codec); }
@Override public void operationComplete(ChannelFuture future) throws Exception { if (!future.isSuccess()) { log.error("Can't handshake " + sessionId, future.cause()); return; } channel.pipeline().addBefore(SocketIOChannelInitializer.WEB_SOCKET_TRANSPORT, SocketIOChannelInitializer.WEB_SOCKET_AGGREGATOR, new WebSocketFrameAggregator(configuration.getMaxFramePayloadLength())); connectClient(channel, sessionId); } });
void configureHttp2(ChannelPipeline pipeline) { if (options.getIdleTimeout() > 0) { pipeline.addBefore("handler", "idle", new IdleStateHandler(0, 0, options.getIdleTimeout(), options.getIdleTimeoutUnit())); } }
@Override protected void initChannel(Channel ch) { ChannelPipeline pipeline = ch.pipeline() .addLast(HTTP_CLIENT_CODEC, newHttpClientCodec()) .addLast(AHC_WS_HANDLER, wsHandler); if (config.isEnableWebSocketCompression()) { pipeline.addBefore(AHC_WS_HANDLER, WS_COMPRESSOR_HANDLER, WebSocketClientCompressionHandler.INSTANCE); } if (LOGGER.isDebugEnabled()) { pipeline.addFirst(LOGGING_HANDLER, loggingHandler); } if (config.getWsAdditionalChannelInitializer() != null) config.getWsAdditionalChannelInitializer().accept(ch); } });
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof LastHttpContent) { removeInternalHandler(ctx); } else if (msg instanceof HttpRequest) { // Start timeout handler. InternalReadTimeoutHandler handler = new InternalReadTimeoutHandler(timeout, unit); ctx.pipeline().addBefore(HANDLER_NAME, INTERNAL_HANDLER_NAME, handler); } super.channelRead(ctx, msg); }
@Override public ChannelPipeline addLast(EventExecutorGroup group, String name, ChannelHandler handler) { if (null != lastHandlerName) { pipeline.addBefore(group, lastHandlerName, name, handler); } else { pipeline.addLast(group, name, handler); } return this; }
@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { ctx.pipeline() .addBefore(ctx.name(), null, new Http2ServerUpgradeHandler.PriorKnowledgeHandler()) .addBefore(ctx.name(), "HttpServerCodec", httpServerCodec) .replace(this, "HttpServerUpgradeHandler", httpServerUpgradeHandler); }
@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { ctx.pipeline() .addBefore(ctx.name(), null, new Http2ServerUpgradeHandler.PriorKnowledgeHandler()) .addBefore(ctx.name(), "HttpServerCodec", httpServerCodec) .replace(this, "HttpServerUpgradeHandler", httpServerUpgradeHandler); }
@Override protected void addCodec(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); String name = ctx.name(); Socks4ClientDecoder decoder = new Socks4ClientDecoder(); p.addBefore(name, null, decoder); decoderName = p.context(decoder).name(); encoderName = decoderName + ".encoder"; p.addBefore(name, encoderName, Socks4ClientEncoder.INSTANCE); }
@Override protected void addCodec(ChannelHandlerContext ctx) throws Exception { ChannelPipeline p = ctx.pipeline(); String name = ctx.name(); Socks5InitialResponseDecoder decoder = new Socks5InitialResponseDecoder(); p.addBefore(name, null, decoder); decoderName = p.context(decoder).name(); encoderName = decoderName + ".encoder"; p.addBefore(name, encoderName, Socks5ClientEncoder.DEFAULT); }
/** * Setup the required handlers on pipeline using this method. * * @param pipeline */ public void addProxyProtocol(ChannelPipeline pipeline) { pipeline.addLast(NAME, this); if (withProxyProtocol) { pipeline.addBefore(NAME, OptionalHAProxyMessageDecoder.NAME, new OptionalHAProxyMessageDecoder()); } }
public void startReadTimeoutHandler(int readTimeout) { channel.pipeline().addBefore("originNettyLogger", READ_TIMEOUT_HANDLER_NAME, new ReadTimeoutHandler(readTimeout, TimeUnit.MILLISECONDS)); }
void addBeforeSessionHandler(ChannelPipeline pipeline, ChannelHandler handler) { // Get the name of the HttpSessionHandler so that we can put our handlers before it. final ChannelHandlerContext lastContext = pipeline.lastContext(); assert lastContext.handler().getClass() == HttpSessionHandler.class; pipeline.addBefore(lastContext.name(), null, handler); }
@Override public ChannelPipeline addLast(ChannelHandler... handlers) { if (null != lastHandlerName) { for (ChannelHandler handler : handlers) { pipeline.addBefore(lastHandlerName, generateUniqueName(), handler); } } else { pipeline.addLast(handlers); } return this; }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { if (msg instanceof LastHttpContent) { removeInternalHandler(ctx); } else if (msg instanceof HttpRequest) { // Start timeout handler. InternalReadTimeoutHandler handler = new InternalReadTimeoutHandler(timeout, unit); ctx.pipeline().addBefore(HANDLER_NAME, INTERNAL_HANDLER_NAME, handler); } super.channelRead(ctx, msg); }
private void writeClientRequestToOrigin(final PooledConnection conn) { final Channel ch = conn.getChannel(); passport.setOnChannel(ch); context.set(ORIGIN_CHANNEL, ch); context.set(POOLED_ORIGIN_CONNECTION_KEY, conn); preWriteToOrigin(chosenServer.get(), zuulRequest); final ChannelPipeline pipeline = ch.pipeline(); originResponseReceiver = getOriginResponseReceiver(); pipeline.addBefore("connectionPoolHandler", OriginResponseReceiver.CHANNEL_HANDLER_NAME, originResponseReceiver); // check if body needs to be repopulated for retry repopulateRetryBody(); ch.write(zuulRequest); writeBufferedBodyContent(zuulRequest, ch); ch.flush(); //Get ready to read origin's response ch.read(); originConn = conn; channelCtx.read(); }
private void writeClientRequestToOrigin(final PooledConnection conn) { final Channel ch = conn.getChannel(); passport.setOnChannel(ch); context.set(ORIGIN_CHANNEL, ch); context.set(POOLED_ORIGIN_CONNECTION_KEY, conn); preWriteToOrigin(chosenServer.get(), zuulRequest); final ChannelPipeline pipeline = ch.pipeline(); originResponseReceiver = getOriginResponseReceiver(); pipeline.addBefore("connectionPoolHandler", OriginResponseReceiver.CHANNEL_HANDLER_NAME, originResponseReceiver); // check if body needs to be repopulated for retry repopulateRetryBody(); ch.write(zuulRequest); writeBufferedBodyContent(zuulRequest, ch); ch.flush(); //Get ready to read origin's response ch.read(); originConn = conn; channelCtx.read(); }