Package org.mockserver.netty.proxy.relay
Class LoopbackHttp2ConnectionCloseHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
org.mockserver.netty.proxy.relay.LoopbackHttp2ConnectionCloseHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class LoopbackHttp2ConnectionCloseHandler
extends io.netty.channel.ChannelInboundHandlerAdapter
Ends the proxy client's HTTP/2 streams at once when the CONNECT/SOCKS relay's HTTP/2 loopback connection closes, for
any reason, instead of leaving them to Netty's 30 s graceful-shutdown timeout. The client is sent a
GOAWAY,
then each active stream that has no whole response is reset: REFUSED_STREAM when no request on it has been
relayed, so MockServer never saw it and RFC 9113 section 8.7 lets the client retry it, otherwise
INTERNAL_ERROR, since MockServer may have acted on it. A stream whose whole response has been relayed is not
cut short: while the response is still queued behind the client's flow-control window it is left to finish.
DownstreamProxyRelayHandler then closes the client connection gracefully, which waits only for those
responses.
A GOAWAY the loopback receives is passed on to the client, so it opens new streams on another connection
rather than on this one, whose loopback can no longer carry them. Sits after LoopbackHttp2StreamIdRemapper,
which records which client streams have been relayed and answered, and before
DownstreamProxyRelayHandler; one per loopback. It calls the client's Http2ConnectionHandler
directly, which is safe only because the loopback shares the client's event loop.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
ConstructorsConstructorDescriptionLoopbackHttp2ConnectionCloseHandler(org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.handler.codec.http2.Http2Connection loopbackConnection, io.netty.channel.Channel proxyClientChannel, LoopbackHttp2StreamIdRemapper streamIdRemapper) -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
LoopbackHttp2ConnectionCloseHandler
public LoopbackHttp2ConnectionCloseHandler(org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.handler.codec.http2.Http2Connection loopbackConnection, io.netty.channel.Channel proxyClientChannel, LoopbackHttp2StreamIdRemapper streamIdRemapper)
-
-
Method Details
-
channelInactive
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-