HpackDecoder Class — netty Architecture
Architecture documentation for the HpackDecoder class in HpackDecoder.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 929eb7d3_94e9_fa41_fd78_c76a9b499b89["HpackDecoder"] 0349111a_08cf_8a81_958c_9daf941c0bac["HpackDecoder.java"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|defined in| 0349111a_08cf_8a81_958c_9daf941c0bac 50441644_f344_0b29_398e_ab5f2214ee3d["HpackDecoder()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| 50441644_f344_0b29_398e_ab5f2214ee3d f902eae9_e223_3289_c748_bbdc7d188389["decode()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| f902eae9_e223_3289_c748_bbdc7d188389 337bdce6_5a9c_2e66_9239_9ac5320a87fe["decodeDynamicTableSizeUpdates()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| 337bdce6_5a9c_2e66_9239_9ac5320a87fe ecd1eadc_7179_c56c_27b9_d01dfe58533c["setMaxHeaderTableSize()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| ecd1eadc_7179_c56c_27b9_d01dfe58533c 14254632_9488_30a0_fc51_dfa1c27e0883["setMaxHeaderListSize()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| 14254632_9488_30a0_fc51_dfa1c27e0883 f32a66af_2140_8a4a_2dcd_8b3aa0adb8f4["getMaxHeaderListSize()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| f32a66af_2140_8a4a_2dcd_8b3aa0adb8f4 2cb39259_e298_b5b5_eb35_e89960061bc3["getMaxHeaderTableSize()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| 2cb39259_e298_b5b5_eb35_e89960061bc3 9ddcd0d7_f2a7_3eb8_850c_c3ab8a1f637f["length()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| 9ddcd0d7_f2a7_3eb8_850c_c3ab8a1f637f 83a74a6f_65f9_5ac1_b9fb_ccf931431460["size()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| 83a74a6f_65f9_5ac1_b9fb_ccf931431460 920fe590_8969_bc7e_33d4_84ccadf1debf["HpackHeaderField()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| 920fe590_8969_bc7e_33d4_84ccadf1debf 3628d393_8a90_23ae_a124_8340f5dabacf["setDynamicTableSize()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| 3628d393_8a90_23ae_a124_8340f5dabacf c1b5aae4_50f3_8c8a_1313_f22971fe17cd["HeaderType()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| c1b5aae4_50f3_8c8a_1313_f22971fe17cd 9460e2c3_1533_4ca7_d387_d78b34c4564f["AsciiString()"] 929eb7d3_94e9_fa41_fd78_c76a9b499b89 -->|method| 9460e2c3_1533_4ca7_d387_d78b34c4564f
Relationship Graph
Source Code
codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDecoder.java lines 54–571
final class HpackDecoder {
private static final Http2Exception DECODE_ULE_128_DECOMPRESSION_EXCEPTION =
Http2Exception.newStatic(COMPRESSION_ERROR, "HPACK - decompression failure",
Http2Exception.ShutdownHint.HARD_SHUTDOWN, HpackDecoder.class,
"decodeULE128(..)");
private static final Http2Exception DECODE_ULE_128_TO_LONG_DECOMPRESSION_EXCEPTION =
Http2Exception.newStatic(COMPRESSION_ERROR, "HPACK - long overflow",
Http2Exception.ShutdownHint.HARD_SHUTDOWN, HpackDecoder.class, "decodeULE128(..)");
private static final Http2Exception DECODE_ULE_128_TO_INT_DECOMPRESSION_EXCEPTION =
Http2Exception.newStatic(COMPRESSION_ERROR, "HPACK - int overflow",
Http2Exception.ShutdownHint.HARD_SHUTDOWN, HpackDecoder.class, "decodeULE128ToInt(..)");
private static final Http2Exception DECODE_ILLEGAL_INDEX_VALUE =
Http2Exception.newStatic(COMPRESSION_ERROR, "HPACK - illegal index value",
Http2Exception.ShutdownHint.HARD_SHUTDOWN, HpackDecoder.class, "decode(..)");
private static final Http2Exception INDEX_HEADER_ILLEGAL_INDEX_VALUE =
Http2Exception.newStatic(COMPRESSION_ERROR, "HPACK - illegal index value",
Http2Exception.ShutdownHint.HARD_SHUTDOWN, HpackDecoder.class, "indexHeader(..)");
private static final Http2Exception READ_NAME_ILLEGAL_INDEX_VALUE =
Http2Exception.newStatic(COMPRESSION_ERROR, "HPACK - illegal index value",
Http2Exception.ShutdownHint.HARD_SHUTDOWN, HpackDecoder.class, "readName(..)");
private static final Http2Exception INVALID_MAX_DYNAMIC_TABLE_SIZE =
Http2Exception.newStatic(COMPRESSION_ERROR, "HPACK - invalid max dynamic table size",
Http2Exception.ShutdownHint.HARD_SHUTDOWN, HpackDecoder.class,
"setDynamicTableSize(..)");
private static final Http2Exception MAX_DYNAMIC_TABLE_SIZE_CHANGE_REQUIRED =
Http2Exception.newStatic(COMPRESSION_ERROR, "HPACK - max dynamic table size change required",
Http2Exception.ShutdownHint.HARD_SHUTDOWN, HpackDecoder.class, "decode(..)");
private static final byte READ_HEADER_REPRESENTATION = 0;
private static final byte READ_INDEXED_HEADER = 1;
private static final byte READ_INDEXED_HEADER_NAME = 2;
private static final byte READ_LITERAL_HEADER_NAME_LENGTH_PREFIX = 3;
private static final byte READ_LITERAL_HEADER_NAME_LENGTH = 4;
private static final byte READ_LITERAL_HEADER_NAME = 5;
private static final byte READ_LITERAL_HEADER_VALUE_LENGTH_PREFIX = 6;
private static final byte READ_LITERAL_HEADER_VALUE_LENGTH = 7;
private static final byte READ_LITERAL_HEADER_VALUE = 8;
private final HpackHuffmanDecoder huffmanDecoder = new HpackHuffmanDecoder();
private final HpackDynamicTable hpackDynamicTable;
private long maxHeaderListSize;
private long maxDynamicTableSize;
private long encoderMaxDynamicTableSize;
private boolean maxDynamicTableSizeChangeRequired;
/**
* Create a new instance.
* @param maxHeaderListSize This is the only setting that can be configured before notifying the peer.
* This is because <a href="https://tools.ietf.org/html/rfc7540#section-6.5.1">SETTINGS_MAX_HEADER_LIST_SIZE</a>
* allows a lower than advertised limit from being enforced, and the default limit is unlimited
* (which is dangerous).
*/
HpackDecoder(long maxHeaderListSize) {
this(maxHeaderListSize, DEFAULT_HEADER_TABLE_SIZE);
}
/**
* Exposed Used for testing only! Default values used in the initial settings frame are overridden intentionally
* for testing but violate the RFC if used outside the scope of testing.
*/
HpackDecoder(long maxHeaderListSize, int maxHeaderTableSize) {
this.maxHeaderListSize = checkPositive(maxHeaderListSize, "maxHeaderListSize");
maxDynamicTableSize = encoderMaxDynamicTableSize = maxHeaderTableSize;
maxDynamicTableSizeChangeRequired = false;
hpackDynamicTable = new HpackDynamicTable(maxHeaderTableSize);
}
/**
* Decode the header block into header fields.
* <p>
* This method assumes the entire header block is contained in {@code in}.
*/
void decode(int streamId, ByteBuf in, Http2Headers headers, boolean validateHeaders) throws Http2Exception {
Http2HeadersSink sink = new Http2HeadersSink(
streamId, headers, maxHeaderListSize, validateHeaders);
// Check for dynamic table size updates, which must occur at the beginning:
// https://www.rfc-editor.org/rfc/rfc7541.html#section-4.2
decodeDynamicTableSizeUpdates(in);
decode(in, sink);
// Now that we've read all of our headers we can perform the validation steps. We must
Source
Frequently Asked Questions
What is the HpackDecoder class?
HpackDecoder is a class in the netty codebase, defined in codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDecoder.java.
Where is HpackDecoder defined?
HpackDecoder is defined in codec-http2/src/main/java/io/netty/handler/codec/http2/HpackDecoder.java at line 54.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free