Class QpackEncoder

  • All Implemented Interfaces:
    Dumpable

    public class QpackEncoder
    extends java.lang.Object
    implements Dumpable
    • Field Detail

      • DO_NOT_HUFFMAN

        public static final java.util.EnumSet<HttpHeader> DO_NOT_HUFFMAN
      • DO_NOT_INDEX

        public static final java.util.EnumSet<HttpHeader> DO_NOT_INDEX
      • NEVER_INDEX

        public static final java.util.EnumSet<HttpHeader> NEVER_INDEX
    • Constructor Detail

    • Method Detail

      • getMaxBlockedStreams

        public int getMaxBlockedStreams()
      • setMaxBlockedStreams

        public void setMaxBlockedStreams​(int maxBlockedStreams)
      • getCapacity

        public int getCapacity()
      • setCapacity

        public void setCapacity​(int capacity)
        Set the capacity of the DynamicTable and send a instruction to set the capacity on the remote Decoder.
        Parameters:
        capacity - the new capacity.
      • encode

        public void encode​(java.nio.ByteBuffer buffer,
                           long streamId,
                           MetaData metadata)
                    throws QpackException

        Encodes a MetaData object into the supplied ByteBuffer for a specific HTTP/s stream.

        This method may generate instructions to be sent back over the Encoder stream to the remote Decoder.

        The given buffer is filled starting from its current position p with N encoded bytes and upon return its position will be p + N.

        Parameters:
        buffer - the buffer to take the bytes of the encoded MetaData.
        streamId - the stream ID corresponding to this headers frame.
        metadata - the MetaData to encode into the buffer.
        Throws:
        QpackException - if there was an error with the QPACK compression.
      • parseInstructions

        public void parseInstructions​(java.nio.ByteBuffer buffer)
                               throws QpackException
        Parse instructions from the Decoder stream. The Decoder stream carries an unframed sequence of instructions from the Decoder to the Encoder. This method will fully consume the supplied ByteBuffer and produce instructions to update the state of the Encoder and its Dynamic Table.
        Parameters:
        buffer - a buffer containing bytes from the Decoder stream.
        Throws:
        QpackException - if there was an error parsing or handling the instructions.
      • insert

        public boolean insert​(HttpField field)
        A speculative insert of a Header into the Encoders Dynamic Table. This will also generate an instruction to be sent over the Encoder stream to the remote Decoder.
        Parameters:
        field - the field to insert into the Dynamic Table.
        Returns:
        true if the field was successfully inserted into the Dynamic Table.
      • streamCancellation

        public void streamCancellation​(long streamId)
        Tells the QpackEncoder that a particular stream has been cancelled. Any state stored for this stream will be discarded. The encoder may also receive a stream cancellation instruction from the remote Decoder to cancel the stream which will be a noop if this method was called on the local encoder first.
        Parameters:
        streamId - the streamId of the stream that was cancelled.
      • shouldIndex

        protected boolean shouldIndex​(HttpField httpField)
      • shouldHuffmanEncode

        protected boolean shouldHuffmanEncode​(HttpField httpField)
      • dump

        public void dump​(java.lang.Appendable out,
                         java.lang.String indent)
                  throws java.io.IOException
        Description copied from interface: Dumpable
        Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
        Specified by:
        dump in interface Dumpable
        Parameters:
        out - The appendable to dump to
        indent - The indent to apply after any new lines.
        Throws:
        java.io.IOException - if unable to write to Appendable