Class Http2EventAdapter

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int onDataRead​(io.netty.channel.ChannelHandlerContext ctx, int streamId, io.netty.buffer.ByteBuf data, int padding, boolean endOfStream)
      Handles an inbound DATA frame.
      void onGoAwayRead​(io.netty.channel.ChannelHandlerContext ctx, int lastStreamId, long errorCode, io.netty.buffer.ByteBuf debugData)
      Handles an inbound GO_AWAY frame.
      void onGoAwayReceived​(int lastStreamId, long errorCode, io.netty.buffer.ByteBuf debugData)
      Called when a GOAWAY was received from the remote endpoint.
      void onGoAwaySent​(int lastStreamId, long errorCode, io.netty.buffer.ByteBuf debugData)
      Called when a GOAWAY frame was sent for the connection.
      void onHeadersRead​(io.netty.channel.ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endStream)
      Handles an inbound HEADERS frame.
      void onHeadersRead​(io.netty.channel.ChannelHandlerContext ctx, int streamId, Http2Headers headers, int streamDependency, short weight, boolean exclusive, int padding, boolean endStream)
      Handles an inbound HEADERS frame with priority information specified.
      void onPingAckRead​(io.netty.channel.ChannelHandlerContext ctx, long data)
      Handles an inbound PING acknowledgment.
      void onPingRead​(io.netty.channel.ChannelHandlerContext ctx, long data)
      Handles an inbound PING frame.
      void onPriorityRead​(io.netty.channel.ChannelHandlerContext ctx, int streamId, int streamDependency, short weight, boolean exclusive)
      Handles an inbound PRIORITY frame.
      void onPushPromiseRead​(io.netty.channel.ChannelHandlerContext ctx, int streamId, int promisedStreamId, Http2Headers headers, int padding)
      Handles an inbound PUSH_PROMISE frame.
      void onRstStreamRead​(io.netty.channel.ChannelHandlerContext ctx, int streamId, long errorCode)
      Handles an inbound RST_STREAM frame.
      void onSettingsAckRead​(io.netty.channel.ChannelHandlerContext ctx)
      Handles an inbound SETTINGS acknowledgment frame.
      void onSettingsRead​(io.netty.channel.ChannelHandlerContext ctx, Http2Settings settings)
      Handles an inbound SETTINGS frame.
      void onStreamActive​(Http2Stream stream)
      Notifies the listener that the given stream was made active (i.e.
      void onStreamAdded​(Http2Stream stream)
      Notifies the listener that the given stream was added to the connection.
      void onStreamClosed​(Http2Stream stream)
      Notifies the listener that the given stream is now CLOSED in both directions and will no longer be accessible via Http2Connection.forEachActiveStream(Http2StreamVisitor).
      void onStreamHalfClosed​(Http2Stream stream)
      Notifies the listener that the given stream has transitioned from OPEN to HALF CLOSED.
      void onStreamRemoved​(Http2Stream stream)
      Notifies the listener that the given stream has now been removed from the connection and will no longer be returned via Http2Connection.stream(int).
      void onUnknownFrame​(io.netty.channel.ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, io.netty.buffer.ByteBuf payload)
      Handler for a frame not defined by the HTTP/2 spec.
      void onWindowUpdateRead​(io.netty.channel.ChannelHandlerContext ctx, int streamId, int windowSizeIncrement)
      Handles an inbound WINDOW_UPDATE frame.
    • Constructor Detail

      • Http2EventAdapter

        public Http2EventAdapter()
    • Method Detail

      • onDataRead

        public int onDataRead​(io.netty.channel.ChannelHandlerContext ctx,
                              int streamId,
                              io.netty.buffer.ByteBuf data,
                              int padding,
                              boolean endOfStream)
                       throws Http2Exception
        Description copied from interface: Http2FrameListener
        Handles an inbound DATA frame.
        Specified by:
        onDataRead in interface Http2FrameListener
        Parameters:
        ctx - the context from the handler where the frame was read.
        streamId - the subject stream for the frame.
        data - payload buffer for the frame. This buffer will be released by the codec.
        padding - additional bytes that should be added to obscure the true content size. Must be between 0 and 256 (inclusive).
        endOfStream - Indicates whether this is the last frame to be sent from the remote endpoint for this stream.
        Returns:
        the number of bytes that have been processed by the application. The returned bytes are used by the inbound flow controller to determine the appropriate time to expand the inbound flow control window (i.e. send WINDOW_UPDATE). Returning a value equal to the length of data + padding will effectively opt-out of application-level flow control for this frame. Returning a value less than the length of data + padding will defer the returning of the processed bytes, which the application must later return via Http2LocalFlowController.consumeBytes(Http2Stream, int). The returned value must be >= 0 and <= data.readableBytes() + padding.
        Throws:
        Http2Exception
      • onPriorityRead

        public void onPriorityRead​(io.netty.channel.ChannelHandlerContext ctx,
                                   int streamId,
                                   int streamDependency,
                                   short weight,
                                   boolean exclusive)
                            throws Http2Exception
        Description copied from interface: Http2FrameListener
        Handles an inbound PRIORITY frame.

        Note that is it possible to have this method called and no stream object exist for either streamId, streamDependency, or both. This is because the PRIORITY frame can be sent/received when streams are in the CLOSED state.

        Specified by:
        onPriorityRead in interface Http2FrameListener
        Parameters:
        ctx - the context from the handler where the frame was read.
        streamId - the subject stream for the frame.
        streamDependency - the stream on which this stream depends, or 0 if dependent on the connection.
        weight - the new weight for the stream.
        exclusive - whether or not the stream should be the exclusive dependent of its parent.
        Throws:
        Http2Exception
      • onRstStreamRead

        public void onRstStreamRead​(io.netty.channel.ChannelHandlerContext ctx,
                                    int streamId,
                                    long errorCode)
                             throws Http2Exception
        Description copied from interface: Http2FrameListener
        Handles an inbound RST_STREAM frame.
        Specified by:
        onRstStreamRead in interface Http2FrameListener
        Parameters:
        ctx - the context from the handler where the frame was read.
        streamId - the stream that is terminating.
        errorCode - the error code identifying the type of failure.
        Throws:
        Http2Exception
      • onPingRead

        public void onPingRead​(io.netty.channel.ChannelHandlerContext ctx,
                               long data)
                        throws Http2Exception
        Description copied from interface: Http2FrameListener
        Handles an inbound PING frame.
        Specified by:
        onPingRead in interface Http2FrameListener
        Parameters:
        ctx - the context from the handler where the frame was read.
        data - the payload of the frame.
        Throws:
        Http2Exception
      • onPingAckRead

        public void onPingAckRead​(io.netty.channel.ChannelHandlerContext ctx,
                                  long data)
                           throws Http2Exception
        Description copied from interface: Http2FrameListener
        Handles an inbound PING acknowledgment.
        Specified by:
        onPingAckRead in interface Http2FrameListener
        Parameters:
        ctx - the context from the handler where the frame was read.
        data - the payload of the frame.
        Throws:
        Http2Exception
      • onGoAwayRead

        public void onGoAwayRead​(io.netty.channel.ChannelHandlerContext ctx,
                                 int lastStreamId,
                                 long errorCode,
                                 io.netty.buffer.ByteBuf debugData)
                          throws Http2Exception
        Description copied from interface: Http2FrameListener
        Handles an inbound GO_AWAY frame.
        Specified by:
        onGoAwayRead in interface Http2FrameListener
        Parameters:
        ctx - the context from the handler where the frame was read.
        lastStreamId - the last known stream of the remote endpoint.
        errorCode - the error code, if abnormal closure.
        debugData - application-defined debug data. If this buffer needs to be retained by the listener they must make a copy.
        Throws:
        Http2Exception
      • onWindowUpdateRead

        public void onWindowUpdateRead​(io.netty.channel.ChannelHandlerContext ctx,
                                       int streamId,
                                       int windowSizeIncrement)
                                throws Http2Exception
        Description copied from interface: Http2FrameListener
        Handles an inbound WINDOW_UPDATE frame.
        Specified by:
        onWindowUpdateRead in interface Http2FrameListener
        Parameters:
        ctx - the context from the handler where the frame was read.
        streamId - the stream the frame was sent on.
        windowSizeIncrement - the increased number of bytes of the remote endpoint's flow control window.
        Throws:
        Http2Exception
      • onUnknownFrame

        public void onUnknownFrame​(io.netty.channel.ChannelHandlerContext ctx,
                                   byte frameType,
                                   int streamId,
                                   Http2Flags flags,
                                   io.netty.buffer.ByteBuf payload)
                            throws Http2Exception
        Description copied from interface: Http2FrameListener
        Handler for a frame not defined by the HTTP/2 spec.
        Specified by:
        onUnknownFrame in interface Http2FrameListener
        Parameters:
        ctx - the context from the handler where the frame was read.
        frameType - the frame type from the HTTP/2 header.
        streamId - the stream the frame was sent on.
        flags - the flags in the frame header.
        payload - the payload of the frame.
        Throws:
        Http2Exception
      • onStreamAdded

        public void onStreamAdded​(Http2Stream stream)
        Description copied from interface: Http2Connection.Listener
        Notifies the listener that the given stream was added to the connection. This stream may not yet be active (i.e. OPEN or HALF CLOSED).

        If a RuntimeException is thrown it will be logged and not propagated. Throwing from this method is not supported and is considered a programming error.

        Specified by:
        onStreamAdded in interface Http2Connection.Listener
      • onGoAwaySent

        public void onGoAwaySent​(int lastStreamId,
                                 long errorCode,
                                 io.netty.buffer.ByteBuf debugData)
        Description copied from interface: Http2Connection.Listener
        Called when a GOAWAY frame was sent for the connection.

        If a RuntimeException is thrown it will be logged and not propagated. Throwing from this method is not supported and is considered a programming error.

        Specified by:
        onGoAwaySent in interface Http2Connection.Listener
        Parameters:
        lastStreamId - the last known stream of the remote endpoint.
        errorCode - the error code, if abnormal closure.
        debugData - application-defined debug data.
      • onGoAwayReceived

        public void onGoAwayReceived​(int lastStreamId,
                                     long errorCode,
                                     io.netty.buffer.ByteBuf debugData)
        Description copied from interface: Http2Connection.Listener
        Called when a GOAWAY was received from the remote endpoint. This event handler duplicates Http2FrameListener.onGoAwayRead(io.netty.channel.ChannelHandlerContext, int, long, ByteBuf) but is added here in order to simplify application logic for handling GOAWAY in a uniform way. An application should generally not handle both events, but if it does this method is called second, after notifying the Http2FrameListener.

        If a RuntimeException is thrown it will be logged and not propagated. Throwing from this method is not supported and is considered a programming error.

        Specified by:
        onGoAwayReceived in interface Http2Connection.Listener
        Parameters:
        lastStreamId - the last known stream of the remote endpoint.
        errorCode - the error code, if abnormal closure.
        debugData - application-defined debug data.