Class InboundHttp2ToHttpAdapter

    • Field Detail

      • validateHttpHeaders

        protected final boolean validateHttpHeaders
    • Constructor Detail

      • InboundHttp2ToHttpAdapter

        protected InboundHttp2ToHttpAdapter​(Http2Connection connection,
                                            int maxContentLength,
                                            boolean validateHttpHeaders,
                                            boolean propagateSettings)
    • Method Detail

      • removeMessage

        protected final void removeMessage​(Http2Stream stream,
                                           boolean release)
        The stream is out of scope for the HTTP message flow and will no longer be tracked
        Parameters:
        stream - The stream to remove associated state with
        release - true to call release on the value if it is present. false to not call release.
      • getMessage

        protected final io.netty.handler.codec.http.FullHttpMessage getMessage​(Http2Stream stream)
        Get the FullHttpMessage associated with stream.
        Parameters:
        stream - The stream to get the associated state from
        Returns:
        The FullHttpMessage associated with stream.
      • putMessage

        protected final void putMessage​(Http2Stream stream,
                                        io.netty.handler.codec.http.FullHttpMessage message)
        Make message be the state associated with stream.
        Parameters:
        stream - The stream which message is associated with.
        message - The message which contains the HTTP semantics.
      • fireChannelRead

        protected void fireChannelRead​(io.netty.channel.ChannelHandlerContext ctx,
                                       io.netty.handler.codec.http.FullHttpMessage msg,
                                       boolean release,
                                       Http2Stream stream)
        Set final headers and fire a channel read event
        Parameters:
        ctx - The context to fire the event on
        msg - The message to send
        release - true to call release on the value if it is present. false to not call release.
        stream - the stream of the message which is being fired
      • newMessage

        protected io.netty.handler.codec.http.FullHttpMessage newMessage​(Http2Stream stream,
                                                                         Http2Headers headers,
                                                                         boolean validateHttpHeaders,
                                                                         io.netty.buffer.ByteBufAllocator alloc)
                                                                  throws Http2Exception
        Create a new FullHttpMessage based upon the current connection parameters
        Parameters:
        stream - The stream to create a message for
        headers - The headers associated with stream
        validateHttpHeaders -
        • true to validate HTTP headers in the http-codec
        • false not to validate HTTP headers in the http-codec
        alloc - The ByteBufAllocator to use to generate the content of the message
        Throws:
        Http2Exception - If there is an error when creating FullHttpMessage from Http2Stream and Http2Headers
      • processHeadersBegin

        protected io.netty.handler.codec.http.FullHttpMessage processHeadersBegin​(io.netty.channel.ChannelHandlerContext ctx,
                                                                                  Http2Stream stream,
                                                                                  Http2Headers headers,
                                                                                  boolean endOfStream,
                                                                                  boolean allowAppend,
                                                                                  boolean appendToTrailer)
                                                                           throws Http2Exception
        Provides translation between HTTP/2 and HTTP header objects while ensuring the stream is in a valid state for additional headers.
        Parameters:
        ctx - The context for which this message has been received. Used to send informational header if detected.
        stream - The stream the headers apply to
        headers - The headers to process
        endOfStream - true if the stream has received the end of stream flag
        allowAppend -
        • true if headers will be appended if the stream already exists.
        • if false and the stream already exists this method returns null.
        appendToTrailer -
        • true if a message stream already exists then the headers should be added to the trailing headers.
        • false then appends will be done to the initial headers.
        Returns:
        The object used to track the stream corresponding to stream. null if allowAppend is false and the stream already exists.
        Throws:
        Http2Exception - If the stream id is not in the correct state to process the headers request
      • 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
        Overrides:
        onDataRead in class Http2EventAdapter
        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
      • 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
        Overrides:
        onRstStreamRead in class Http2EventAdapter
        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
      • onRstStreamRead

        protected void onRstStreamRead​(Http2Stream stream,
                                       io.netty.handler.codec.http.FullHttpMessage msg)
        Called if a RST_STREAM is received but we have some data for that stream.