Class Http2ConnectionWindow

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.micronaut.http.server.netty.handler.Http2ConnectionWindow
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

@Internal public final class Http2ConnectionWindow extends io.netty.channel.ChannelInboundHandlerAdapter
Raises the receive window of the HTTP/2 connection as a whole (stream 0) once the connection preface has been sent. SETTINGS_INITIAL_WINDOW_SIZE only sets the window of each stream; the connection window starts at Http2CodecUtil.DEFAULT_WINDOW_SIZE and can only be raised with a WINDOW_UPDATE on stream 0.

The Http2ServerHandler does this itself. This handler is for pipelines built around netty's Http2FrameCodec, which cannot be extended: it is added right after the codec, raises the window and then removes itself.

Since:
5.2.2
Author:
Graeme Rocher
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Constructor Summary

    Constructors
    Constructor
    Description
    Http2ConnectionWindow(io.netty.handler.codec.http2.Http2ConnectionHandler connectionHandler, int windowSize)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelActive(io.netty.channel.ChannelHandlerContext ctx)
     
    static int
    effectiveWindowSize(io.netty.handler.codec.http2.Http2Settings initialSettings, @Nullable Integer configured)
    Compute the connection window size to use for the given settings: the larger of the configured value and the window derived from the stream window.
    void
    handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
     
    static void
    raise(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http2.Http2Connection connection, int windowSize)
    Raise the connection window of the given connection to windowSize if it is smaller, and advertise the increase to the peer right away.

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

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

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerRemoved, isSharable

    Methods inherited from class Object

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

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerRemoved
  • Constructor Details

    • Http2ConnectionWindow

      public Http2ConnectionWindow(io.netty.handler.codec.http2.Http2ConnectionHandler connectionHandler, int windowSize)
      Parameters:
      connectionHandler - The connection handler whose connection window to raise
      windowSize - The target window size, see effectiveWindowSize(Http2Settings, Integer)
  • Method Details

    • effectiveWindowSize

      public static int effectiveWindowSize(io.netty.handler.codec.http2.Http2Settings initialSettings, @Nullable Integer configured)
      Compute the connection window size to use for the given settings: the larger of the configured value and the window derived from the stream window. The derived window follows the rule of netty's Http2FrameCodec, which raises the connection window by twice the amount the stream window exceeds the protocol default, so that a single stream cannot use up the whole connection window. The codec applies that rule on its own, so a configured value cannot go below it in the legacy pipeline; using the same floor here keeps both pipelines consistent.
      Parameters:
      initialSettings - The local settings sent in the preface
      configured - The explicitly configured connection window size, if any
      Returns:
      The connection window size, at least Http2CodecUtil.DEFAULT_WINDOW_SIZE
    • raise

      public static void raise(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http2.Http2Connection connection, int windowSize) throws io.netty.handler.codec.http2.Http2Exception
      Raise the connection window of the given connection to windowSize if it is smaller, and advertise the increase to the peer right away. Must be called on the event loop after the preface has been sent, so that the WINDOW_UPDATE follows the SETTINGS frame.
      Parameters:
      ctx - The context of the connection handler
      connection - The connection
      windowSize - The target window size
      Throws:
      io.netty.handler.codec.http2.Http2Exception - If the flow controller rejects the update
    • handlerAdded

      public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) throws Exception
      Specified by:
      handlerAdded in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerAdded in class io.netty.channel.ChannelHandlerAdapter
      Throws:
      Exception
    • channelActive

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