Class DelegatingDecompressorFrameListener

  • All Implemented Interfaces:
    Http2FrameListener

    public class DelegatingDecompressorFrameListener
    extends Http2FrameListenerDecorator
    An HTTP2 frame listener that will decompress data frames according to the content-encoding header for each stream. The decompression provided by this class will be applied to the data for the entire stream.
    • 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
        Overrides:
        onDataRead in class Http2FrameListenerDecorator
        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
      • newContentDecompressor

        protected io.netty.channel.embedded.EmbeddedChannel newContentDecompressor​(io.netty.channel.ChannelHandlerContext ctx,
                                                                                   CharSequence contentEncoding)
                                                                            throws Http2Exception
        Returns a new EmbeddedChannel that decodes the HTTP2 message content encoded in the specified contentEncoding.
        Parameters:
        contentEncoding - the value of the content-encoding header
        Returns:
        a new ByteToMessageDecoder if the specified encoding is supported. null otherwise (alternatively, you can throw a Http2Exception to block unknown encoding).
        Throws:
        Http2Exception - If the specified encoding is not supported and warrants an exception
      • getTargetContentEncoding

        protected CharSequence getTargetContentEncoding​(CharSequence contentEncoding)
                                                 throws Http2Exception
        Returns the expected content encoding of the decoded content. This getMethod returns "identity" by default, which is the case for most decompressors.
        Parameters:
        contentEncoding - the value of the content-encoding header
        Returns:
        the expected content encoding of the new content.
        Throws:
        Http2Exception - if the contentEncoding is not supported and warrants an exception