Class Http2Handler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

    @Sharable
    public final class Http2Handler
    extends AsyncHttpClientHandler
    HTTP/2 channel handler for stream child channels created by Http2MultiplexHandler.

    Each HTTP/2 stream is represented as a child channel. This handler is attached to each stream child channel and processes Http2HeadersFrame (response status + headers) and Http2DataFrame (response body) frames directly for maximum performance — no HTTP/1.1 object conversion overhead.

    Follows the same structure as HttpHandler and reuses the same interceptor chain, body part factory, and lifecycle methods from AsyncHttpClientHandler.

    • Method Detail

      • userEventTriggered

        public void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx,
                                       Object evt)
                                throws Exception
        Netty's Http2MultiplexHandler delivers RST_STREAM to the stream child channel as a user event (Http2ResetFrame is an Http2StreamFrame), NOT via channelRead. Without this override handleHttp2ResetFrame(io.netty.handler.codec.http2.Http2ResetFrame, io.netty.channel.Channel, org.asynchttpclient.netty.NettyResponseFuture<?>) never runs and the stream is failed only later by the generic channelInactive, discarding the server's RST error code. Handle it here so the stream fails promptly carrying that code, while staying stream-scoped (RFC 7540 §6.4): the parent connection and its sibling multiplexed streams are left untouched.
        Specified by:
        userEventTriggered in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        userEventTriggered in class io.netty.channel.ChannelInboundHandlerAdapter
        Throws:
        Exception