Class Http2ConnectionHandler

    • Method Detail

      • gracefulShutdownTimeoutMillis

        public long gracefulShutdownTimeoutMillis()
        Get the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing the connection during the graceful shutdown process. Returns -1 if this connection is configured to wait indefinitely for all streams to close.
      • gracefulShutdownTimeoutMillis

        public void gracefulShutdownTimeoutMillis​(long gracefulShutdownTimeoutMillis)
        Set the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing the connection during the graceful shutdown process.
        Parameters:
        gracefulShutdownTimeoutMillis - the amount of time (in milliseconds) this endpoint will wait for all streams to be closed before closing the connection during the graceful shutdown process.
      • onHttpClientUpgrade

        public void onHttpClientUpgrade()
                                 throws Http2Exception
        Handles the client-side (cleartext) upgrade from HTTP to HTTP/2. Reserves local stream 1 for the HTTP/2 response.
        Throws:
        Http2Exception
      • onHttpServerUpgrade

        public void onHttpServerUpgrade​(Http2Settings settings)
                                 throws Http2Exception
        Handles the server-side (cleartext) upgrade from HTTP to HTTP/2.
        Parameters:
        settings - the settings for the remote endpoint.
        Throws:
        Http2Exception
      • flush

        public void flush​(io.netty5.channel.ChannelHandlerContext ctx)
        Specified by:
        flush in interface io.netty5.channel.ChannelHandler
      • handlerAdded0

        public void handlerAdded0​(io.netty5.channel.ChannelHandlerContext ctx)
                           throws Exception
        Overrides:
        handlerAdded0 in class io.netty5.handler.codec.ByteToMessageDecoder
        Throws:
        Exception
      • handlerRemoved0

        protected void handlerRemoved0​(io.netty5.channel.ChannelHandlerContext ctx)
                                throws Exception
        Overrides:
        handlerRemoved0 in class io.netty5.handler.codec.ByteToMessageDecoder
        Throws:
        Exception
      • channelActive

        public void channelActive​(io.netty5.channel.ChannelHandlerContext ctx)
                           throws Exception
        Specified by:
        channelActive in interface io.netty5.channel.ChannelHandler
        Throws:
        Exception
      • channelInactive

        public void channelInactive​(io.netty5.channel.ChannelHandlerContext ctx)
                             throws Exception
        Specified by:
        channelInactive in interface io.netty5.channel.ChannelHandler
        Overrides:
        channelInactive in class io.netty5.handler.codec.ByteToMessageDecoder
        Throws:
        Exception
      • channelWritabilityChanged

        public void channelWritabilityChanged​(io.netty5.channel.ChannelHandlerContext ctx)
                                       throws Exception
        Specified by:
        channelWritabilityChanged in interface io.netty5.channel.ChannelHandler
        Throws:
        Exception
      • decode

        protected void decode​(io.netty5.channel.ChannelHandlerContext ctx,
                              io.netty5.buffer.Buffer in)
                       throws Exception
        Specified by:
        decode in class io.netty5.handler.codec.ByteToMessageDecoder
        Throws:
        Exception
      • close

        public io.netty5.util.concurrent.Future<Void> close​(io.netty5.channel.ChannelHandlerContext ctx)
        Specified by:
        close in interface io.netty5.channel.ChannelHandler
      • channelReadComplete

        public void channelReadComplete​(io.netty5.channel.ChannelHandlerContext ctx)
                                 throws Exception
        Specified by:
        channelReadComplete in interface io.netty5.channel.ChannelHandler
        Overrides:
        channelReadComplete in class io.netty5.handler.codec.ByteToMessageDecoder
        Throws:
        Exception
      • channelExceptionCaught

        public void channelExceptionCaught​(io.netty5.channel.ChannelHandlerContext ctx,
                                           Throwable cause)
                                    throws Exception
        Handles Http2Exception objects that were thrown from other handlers. Ignores all other exceptions.
        Specified by:
        channelExceptionCaught in interface io.netty5.channel.ChannelHandler
        Throws:
        Exception
      • closeStreamLocal

        public void closeStreamLocal​(Http2Stream stream,
                                     io.netty5.util.concurrent.Future<Void> future)
        Closes the local side of the given stream. If this causes the stream to be closed, adds a hook to close the channel after the given future completes.
        Specified by:
        closeStreamLocal in interface Http2LifecycleManager
        Parameters:
        stream - the stream to be half closed.
        future - If closing, the future after which to close the channel.
      • closeStreamRemote

        public void closeStreamRemote​(Http2Stream stream,
                                      io.netty5.util.concurrent.Future<Void> future)
        Closes the remote side of the given stream. If this causes the stream to be closed, adds a hook to close the channel after the given future completes.
        Specified by:
        closeStreamRemote in interface Http2LifecycleManager
        Parameters:
        stream - the stream to be half closed.
        future - If closing, the future after which to close the channel.
      • onError

        public void onError​(io.netty5.channel.ChannelHandlerContext ctx,
                            boolean outbound,
                            Throwable cause)
        Central handler for all exceptions caught during HTTP/2 processing.
        Specified by:
        onError in interface Http2LifecycleManager
        Parameters:
        ctx - The context used for communication and buffer allocation if necessary.
        outbound - true if the error was caused by an outbound operation and so the corresponding Promise was failed as well.
        cause - the error.
      • isGracefulShutdownComplete

        protected boolean isGracefulShutdownComplete()
        Called by the graceful shutdown logic to determine when it is safe to close the connection. Returns true if the graceful shutdown has completed and the connection can be safely closed. This implementation just guarantees that there are no active streams. Subclasses may override to provide additional checks.
      • onConnectionError

        protected void onConnectionError​(io.netty5.channel.ChannelHandlerContext ctx,
                                         boolean outbound,
                                         Throwable cause,
                                         Http2Exception http2Ex)
        Handler for a connection error. Sends a GO_AWAY frame to the remote endpoint. Once all streams are closed, the connection is shut down.
        Parameters:
        ctx - the channel context
        outbound - true if the error was caused by an outbound operation.
        cause - the exception that was caught
        http2Ex - the Http2Exception that is embedded in the causality chain. This may be null if it's an unknown exception.
      • onStreamError

        protected void onStreamError​(io.netty5.channel.ChannelHandlerContext ctx,
                                     boolean outbound,
                                     Throwable cause,
                                     Http2Exception.StreamException http2Ex)
        Handler for a stream error. Sends a RST_STREAM frame to the remote endpoint and closes the stream.
        Parameters:
        ctx - the channel context
        outbound - true if the error was caused by an outbound operation.
        cause - the exception that was caught
        http2Ex - the Http2Exception.StreamException that is embedded in the causality chain.
      • handleServerHeaderDecodeSizeError

        protected void handleServerHeaderDecodeSizeError​(io.netty5.channel.ChannelHandlerContext ctx,
                                                         Http2Stream stream)
        Notifies client that this server has received headers that are larger than what it is willing to accept. Override to change behavior.
        Parameters:
        ctx - the channel context
        stream - the Http2Stream on which the header was received
      • resetStream

        public io.netty5.util.concurrent.Future<Void> resetStream​(io.netty5.channel.ChannelHandlerContext ctx,
                                                                  int streamId,
                                                                  long errorCode)
        Description copied from interface: Http2LifecycleManager
        Ensure the stream identified by streamId is reset. If our local state does not indicate the stream has been reset yet then a RST_STREAM will be sent to the peer. If our local state indicates the stream has already been reset then the return status will indicate success without sending anything to the peer.
        Specified by:
        resetStream in interface Http2LifecycleManager
        Parameters:
        ctx - The context used for communication and buffer allocation if necessary.
        streamId - The identifier of the stream to reset.
        errorCode - Justification as to why this stream is being reset. See Http2Error.
        Returns:
        Will be considered successful when the connection and stream state has been updated, and a RST_STREAM frame has been sent to the peer. If the stream state has already been updated and a RST_STREAM frame has been sent then the return status may indicate success immediately.
      • goAway

        public io.netty5.util.concurrent.Future<Void> goAway​(io.netty5.channel.ChannelHandlerContext ctx,
                                                             int lastStreamId,
                                                             long errorCode,
                                                             io.netty5.buffer.Buffer debugData)
        Description copied from interface: Http2LifecycleManager
        Prevents the peer from creating streams and close the connection if errorCode is not Http2Error.NO_ERROR. After this call the peer is not allowed to create any new streams and the local endpoint will be limited to creating streams with stream identifier <= lastStreamId. This may result in sending a GO_AWAY frame (assuming we have not already sent one with Last-Stream-ID <= lastStreamId), or may just return success if a GO_AWAY has previously been sent.
        Specified by:
        goAway in interface Http2LifecycleManager
        Parameters:
        ctx - The context used for communication and buffer allocation if necessary.
        lastStreamId - The last stream that the local endpoint is claiming it will accept.
        errorCode - The rational as to why the connection is being closed. See Http2Error.
        debugData - For diagnostic purposes (carries no semantic value).
        Returns:
        Will be considered successful when the connection and stream state has been updated, and a GO_AWAY frame has been sent to the peer. If the stream state has already been updated and a GO_AWAY frame has been sent then the return status may indicate success immediately.