Class DecodingCallback

java.lang.Object
org.glassfish.grizzly.http2.hpack.DecodingCallback

public abstract class DecodingCallback extends Object
Delivers results of the decoding operation.

Methods of the callback are never called by a decoder with any of the arguments being null.

The callback provides methods for all possible binary representations. This could be useful for implementing an intermediary, logging, debugging, etc.

The callback is an interface in order to interoperate with lambdas (in the most common use case):

 {
     @code
     DecodingCallback callback = (name, value) -> System.out.println(name + ", " + value);
 }
 

Names and values are CharSequences rather than Strings in order to allow users to decide whether or not they need to create objects. A CharSequence might be used in-place, for example, to be appended to an Appendable (e.g. StringBuilder) and then discarded.

That said, if a passed CharSequence needs to outlast the method call, it needs to be copied.

  • Constructor Details

    • DecodingCallback

      public DecodingCallback()
  • Method Details

    • onDecoded

      public abstract void onDecoded(CharSequence name, CharSequence value)
      A method the more specific methods of the callback forward their calls to.
      Parameters:
      name - header name
      value - header value
    • onDecoded

      public void onDecoded(CharSequence name, CharSequence value, boolean sensitive)
      A more finer-grained version of onDecoded(CharSequence, CharSequence) that also reports on value sensitivity.

      Value sensitivity must be considered, for example, when implementing an intermediary. A value is sensitive if it was represented as Literal Header Field Never Indexed.

      It is required that intermediaries MUST use the same representation for encoding this header field in order to protect its value which is not to be put at risk by compressing it.

      The default implementation invokes onDecoded(name, value).

      Parameters:
      name - header name
      value - header value
      sensitive - whether or not the value is sensitive
      See Also:
    • onIndexed

      public void onIndexed(int index, CharSequence name, CharSequence value)
      An Indexed Header Field decoded.

      The default implementation invokes onDecoded(name, value, false).

      Parameters:
      index - index of an entry in the table
      name - header name
      value - header value
    • onLiteral

      public void onLiteral(int index, CharSequence name, CharSequence value, boolean valueHuffman)
      A Literal Header Field without Indexing decoded, where a name was referred by an index.

      The default implementation invokes onDecoded(name, value, false).

      Parameters:
      index - index of an entry in the table
      name - header name
      value - header value
      valueHuffman - if the value was Huffman encoded
    • onLiteral

      public void onLiteral(CharSequence name, boolean nameHuffman, CharSequence value, boolean valueHuffman)
      A Literal Header Field without Indexing decoded, where both a name and a value were literal.

      The default implementation invokes onDecoded(name, value, false).

      Parameters:
      name - header name
      nameHuffman - if the name was Huffman encoded
      value - header value
      valueHuffman - if the value was Huffman encoded
    • onLiteralNeverIndexed

      public void onLiteralNeverIndexed(int index, CharSequence name, CharSequence value, boolean valueHuffman)
      A Literal Header Field Never Indexed decoded, where a name was referred by an index.

      The default implementation invokes onDecoded(name, value, true).

      Parameters:
      index - index of an entry in the table
      name - header name
      value - header value
      valueHuffman - if the value was Huffman encoded
    • onLiteralNeverIndexed

      public void onLiteralNeverIndexed(CharSequence name, boolean nameHuffman, CharSequence value, boolean valueHuffman)
      A Literal Header Field Never Indexed decoded, where both a name and a value were literal.

      The default implementation invokes onDecoded(name, value, true).

      Parameters:
      name - header name
      nameHuffman - if the name was Huffman encoded
      value - header value
      valueHuffman - if the value was Huffman encoded
    • onLiteralWithIndexing

      public void onLiteralWithIndexing(int index, CharSequence name, CharSequence value, boolean valueHuffman)
      A Literal Header Field with Incremental Indexing decoded, where a name was referred by an index.

      The default implementation invokes onDecoded(name, value, false).

      Parameters:
      index - index of an entry in the table
      name - header name
      value - header value
      valueHuffman - if the value was Huffman encoded
    • onLiteralWithIndexing

      public void onLiteralWithIndexing(CharSequence name, boolean nameHuffman, CharSequence value, boolean valueHuffman)
      A Literal Header Field with Incremental Indexing decoded, where both a name and a value were literal.

      The default implementation invokes onDecoded(name, value, false).

      Parameters:
      name - header name
      nameHuffman - if the name was Huffman encoded
      value - header value
      valueHuffman - if the value was Huffman encoded
    • onSizeUpdate

      public void onSizeUpdate(int capacity)
      A Dynamic Table Size Update decoded.

      The default implementation does nothing.

      Parameters:
      capacity - new capacity of the header table