protected Channel parentChannel(ChannelHandlerContext ctx) { return ctx.channel().parent(); }
@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { // Add a handler that just catches the Http2Exception that we fire to tell the codec to gracefully shutdown a connection. // We want to catch it so that it doesn't get logged by the DefaultChannelPipeline as if it was a _real_ // exception. ChannelPipeline parentPipeline = ctx.channel().parent().pipeline(); String handlerName = "h2_exception_swallow_handler"; if (parentPipeline.get(handlerName) == null) { parentPipeline.addLast(handlerName, SWALLOW_EXCEPTION_HANDLER); } }
protected boolean isSsl(final ChannelHandlerContext ctx) { final Channel ch = ctx.channel(); final Channel connChannel = (ch instanceof Http2StreamChannel) ? ch.parent() : ch; return null != connChannel.pipeline().get(SslHandler.class); } }
protected Channel parentChannel(ChannelHandlerContext ctx) { return ctx.channel().parent(); }
@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { // Add a handler that just catches the Http2Exception that we fire to tell the codec to gracefully shutdown a connection. // We want to catch it so that it doesn't get logged by the DefaultChannelPipeline as if it was a _real_ // exception. ChannelPipeline parentPipeline = ctx.channel().parent().pipeline(); String handlerName = "h2_exception_swallow_handler"; if (parentPipeline.get(handlerName) == null) { parentPipeline.addLast(handlerName, SWALLOW_EXCEPTION_HANDLER); } }
@Override public Channel parent() { return delegate.parent(); }
private static Channel connectionChannel(ChannelHandlerContext ctx) { final Channel ch = ctx.channel(); return ch instanceof Http2StreamChannel ? ch.parent() : ch; } }
/** * Gets the protocol of the channel assuming that it has already been negotiated. * * @param channel Channel to get protocol for. * @return Protocol of channel. */ static Protocol getProtocolNow(Channel channel) { // For HTTP/2 the protocol future will be on the parent socket channel return (channel.parent() == null ? channel : channel.parent()) .attr(ChannelAttributeKey.PROTOCOL_FUTURE).get().join(); } }
/** * Gets the protocol of the channel assuming that it has already been negotiated. * * @param channel Channel to get protocol for. * @return Protocol of channel. */ static Protocol getProtocolNow(Channel channel) { // For HTTP/2 the protocol future will be on the parent socket channel return (channel.parent() == null ? channel : channel.parent()) .attr(ChannelAttributeKey.PROTOCOL_FUTURE).get().join(); } }
@PreDestroy public void stop() throws Exception { serverChannel.close(); serverChannel.parent().close(); }
protected boolean isSsl(final ChannelHandlerContext ctx) { final Channel ch = ctx.channel(); final Channel connChannel = (ch instanceof Http2StreamChannel) ? ch.parent() : ch; return null != connChannel.pipeline().get(SslHandler.class); } }
@PreDestroy public void stop() { if ( serverChannel != null ) { serverChannel.close(); serverChannel.parent().close(); } } }
@PreDestroy public void stop() throws Exception { channel.close(); channel.parent().close(); }
@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { // Add a handler that just catches the Http2Exception that we fire to tell the codec to gracefully shutdown a connection. // We want to catch it so that it doesn't get logged by the DefaultChannelPipeline as if it was a _real_ // exception. ChannelPipeline parentPipeline = ctx.channel().parent().pipeline(); String handlerName = "h2_exception_swallow_handler"; if (parentPipeline.get(handlerName) == null) { parentPipeline.addLast(handlerName, SWALLOW_EXCEPTION_HANDLER); } }
@Override public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { byte[] actual = new byte[in.readableBytes()]; in.readBytes(actual); int lastIdx = counter; for (int i = 0; i < actual.length; i++) { assertEquals(data[i + lastIdx], actual[i]); } if (channel.parent() != null) { channel.writeAndFlush(Unpooled.wrappedBuffer(actual)); } counter += actual.length; }
static boolean mustChunkFileTransfer(Connection c, Path file) { // if channel multiplexing a parent channel as an http2 stream if (c.channel().parent() != null && c.channel().parent().pipeline().get(Http2ConnectionHandler.class) != null) { return true; } ChannelPipeline p = c.channel().pipeline(); return p.get(SslHandler.class) != null || p.get(NettyPipeline.CompressionHandler) != null || (!(c.channel().eventLoop() instanceof NioEventLoop) && !"file".equals(file.toUri().getScheme())); }
static boolean mustChunkFileTransfer(Connection c, Path file) { // if channel multiplexing a parent channel as an http2 stream if (c.channel().parent() != null && c.channel().parent().pipeline().get(Http2ConnectionHandler.class) != null) { return true; } ChannelPipeline p = c.channel().pipeline(); return p.get(SslHandler.class) != null || p.get(NettyPipeline.CompressionHandler) != null || (!(c.channel().eventLoop() instanceof NioEventLoop) && !"file".equals(file.toUri().getScheme())); }
@Override public void channelRead0(ChannelHandlerContext ctx, ByteBuf in) throws Exception { byte[] actual = new byte[in.readableBytes()]; in.readBytes(actual); int lastIdx = counter; for (int i = 0; i < actual.length; i ++) { assertEquals(data[i + lastIdx], actual[i]); } if (channel.parent() != null) { channel.write(Unpooled.wrappedBuffer(actual)); } counter += actual.length; }
private void shutdown(ChannelHandlerContext ctx, ComShutdown request) { ACCESSLOGGER.seqId(this.sequenceId).command(request.toString()); ctx.channel().close(); ctx.channel().parent().close(); server.stop(); System.exit(0); }
@Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { assertEquals(data[counter], msg); if (channel.parent() != null) { channel.write(msg); } counter ++; }