Class Http2Handler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- org.asynchttpclient.netty.handler.AsyncHttpClientHandler
-
- org.asynchttpclient.netty.handler.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 byHttp2MultiplexHandler.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) andHttp2DataFrame(response body) frames directly for maximum performance — no HTTP/1.1 object conversion overhead.Follows the same structure as
HttpHandlerand reuses the same interceptor chain, body part factory, and lifecycle methods fromAsyncHttpClientHandler.
-
-
Field Summary
-
Fields inherited from class org.asynchttpclient.netty.handler.AsyncHttpClientHandler
channelManager, config, logger, requestSender
-
-
Constructor Summary
Constructors Constructor Description Http2Handler(AsyncHttpClientConfig config, ChannelManager channelManager, NettyRequestSender requestSender)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidhandleChannelInactive(NettyResponseFuture<?> future)voidhandleException(NettyResponseFuture<?> future, Throwable error)voidhandleRead(io.netty.channel.Channel channel, NettyResponseFuture<?> future, Object e)Handles incoming frames on the HTTP/2 stream child channel.voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt)Netty'sHttp2MultiplexHandlerdelivers RST_STREAM to the stream child channel as a user event (Http2ResetFrameis anHttp2StreamFrame), NOT viachannelRead.-
Methods inherited from class org.asynchttpclient.netty.handler.AsyncHttpClientHandler
channelActive, channelInactive, channelRead, channelReadComplete, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered, channelWritabilityChanged
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Constructor Detail
-
Http2Handler
public Http2Handler(AsyncHttpClientConfig config, ChannelManager channelManager, NettyRequestSender requestSender)
-
-
Method Detail
-
handleRead
public void handleRead(io.netty.channel.Channel channel, NettyResponseFuture<?> future, Object e) throws ExceptionHandles incoming frames on the HTTP/2 stream child channel. Dispatches to the appropriate handler based on frame type.- Specified by:
handleReadin classAsyncHttpClientHandler- Throws:
Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws ExceptionNetty'sHttp2MultiplexHandlerdelivers RST_STREAM to the stream child channel as a user event (Http2ResetFrameis anHttp2StreamFrame), NOT viachannelRead. Without this overridehandleHttp2ResetFrame(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 genericchannelInactive, 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:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
handleException
public void handleException(NettyResponseFuture<?> future, Throwable error)
- Specified by:
handleExceptionin classAsyncHttpClientHandler
-
handleChannelInactive
public void handleChannelInactive(NettyResponseFuture<?> future)
- Specified by:
handleChannelInactivein classAsyncHttpClientHandler
-
-