Class NBitStringDecoder
java.lang.Object
org.eclipse.jetty.http.compression.NBitStringDecoder
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptiondecode
(ByteBuffer buffer) Decode a string from the buffer.void
reset()
void
setPrefix
(int prefix) Set the prefix length in of the string representation in bits.
-
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
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 withsetPrefix(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()
-