Class NBitStringDecoder

java.lang.Object
org.eclipse.jetty.http.compression.NBitStringDecoder

public class NBitStringDecoder extends Object

Used to decode string literals as described in RFC7541.

The string literal representation consists of a single bit to indicate whether huffman encoding is used, followed by the string byte length encoded with the n-bit integer representation also from RFC7541, and the bytes of the string are directly after this.

Characters which are illegal field-vchar values are replaced with either ' ' or '?' as described in RFC9110

  • Constructor Details

    • NBitStringDecoder

      public NBitStringDecoder()
  • Method Details

    • setPrefix

      public void setPrefix(int prefix)
      Set the prefix length in of the string representation in bits. A prefix of 6 means the string representation starts after the first 2 bits.
      Parameters:
      prefix - the number of bits in the string prefix.
    • decode

      public String decode(ByteBuffer buffer) throws EncodingException
      Decode a string from the buffer. If the buffer does not contain the complete string representation then a value of null is returned to indicate that more data is needed to complete parsing. This should be only after the prefix has been set with setPrefix(int).
      Parameters:
      buffer - the buffer containing the encoded string.
      Returns:
      the decoded string or null to indicate that more data is needed.
      Throws:
      ArithmeticException - if the string length value overflows a int.
      EncodingException - if the string encoding is invalid.
    • reset

      public void reset()