Refine search
private void end(ChannelHandlerContext ctx, ByteBuf buf, boolean h2c) { if (current > 0) { ByteBuf msg = Unpooled.buffer(current + buf.readableBytes()); msg.writeBytes(HTTP_2_PREFACE_ARRAY, 0, current); msg.writeBytes(buf); buf.release(); buf = msg; } configure(ctx, h2c); ctx.pipeline().remove(this); ctx.fireChannelRead(buf); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { try { String clientIP = ctx.channel().attr(SourceAddressChannelHandler.ATTR_SOURCE_ADDRESS).get(); if (IPS.get().contains(clientIP)) { ctx.channel().attr(DynamicHttp2FrameLogger.ATTR_ENABLE).set(Boolean.TRUE); ctx.pipeline().remove(this); } } finally { super.channelRead(ctx, msg); } } }
protected void removeInternalHandler(ChannelHandlerContext ctx) { // Remove timeout handler if not already removed. ChannelHandlerContext handlerContext = ctx.pipeline().context(INTERNAL_HANDLER_NAME); if (handlerContext != null && ! handlerContext.isRemoved()) { ctx.pipeline().remove(INTERNAL_HANDLER_NAME); } }
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception { loggerWire.debug("Decoding handshake... (" + in.readableBytes() + " bytes available)"); decodeHandshake(ctx, in); if (isHandshakeDone) { loggerWire.debug("Handshake done, removing HandshakeHandler from pipeline."); ctx.pipeline().remove(this); } }
public void addLoggingHandler(ChannelHandlerContext ctx) { if (ctx.pipeline().get(LoggingHandler.class) != null) { ctx.pipeline().remove(LoggingHandler.class); } if (ctx.pipeline().get(SslHandler.class) != null) { ctx.pipeline().addAfter("SslHandler#0", "LoggingHandler#0", this); } else { ctx.pipeline().addFirst(this); } }
@SuppressWarnings("unchecked") private boolean initChannel(ChannelHandlerContext ctx) throws Exception { if (initMap.add(ctx)) { // Guard against re-entrance. try { initChannel((C) ctx.channel()); } catch (Throwable cause) { // Explicitly call exceptionCaught(...) as we removed the handler before calling initChannel(...). // We do so to prevent multiple calls to initChannel(...). exceptionCaught(ctx, cause); } finally { ChannelPipeline pipeline = ctx.pipeline(); if (pipeline.context(this) != null) { pipeline.remove(this); } } return true; } return false; }