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

    Constructors
    Constructor
    Description
    LoopbackHttp2ConnectionCloseHandler(org.mockserver.logging.MockServerLogger mockServerLogger, io.netty.handler.codec.http2.Http2Connection loopbackConnection, io.netty.channel.Channel proxyClientChannel, LoopbackHttp2StreamIdRemapper streamIdRemapper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
     

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
      Throws:
      Exception