MCPcopy Index your code
hub / github.com/apache/tomcat / HPackHuffman

Class HPackHuffman

java/org/apache/coyote/http2/HPackHuffman.java:31–701  ·  view source on GitHub ↗

Utility class for Huffman encoding and decoding used in HPACK compression for HTTP/2 headers.

Source from the content-addressed store, hash-verified

29 * Utility class for Huffman encoding and decoding used in HPACK compression for HTTP/2 headers.
30 */
31public class HPackHuffman {
32
33 /**
34 * Private constructor to prevent instantiation.
35 */
36 private HPackHuffman() {
37 }
38
39 /**
40 * String manager for error messages.
41 */
42 protected static final StringManager sm = StringManager.getManager(HPackHuffman.class);
43
44 private static final HuffmanCode[] HUFFMAN_CODES;
45
46 /**
47 * array based tree representation of a huffman code.
48 * <p/>
49 * the high two bytes corresponds to the tree node if the bit is set, and the low two bytes for if it is clear if
50 * the high bit is set it is a terminal node, otherwise it contains the next node position.
51 */
52 private static final int[] DECODING_TABLE;
53
54 private static final int LOW_TERMINAL_BIT = (0b10000000) << 8;
55 private static final int HIGH_TERMINAL_BIT = (0b10000000) << 24;
56 private static final int LOW_MASK = 0b0111111111111111;
57
58
59 static {
60
61 HuffmanCode[] codes = new HuffmanCode[257];
62
63 codes[0] = new HuffmanCode(0x1ff8, 13);
64 codes[1] = new HuffmanCode(0x7fffd8, 23);
65 codes[2] = new HuffmanCode(0xfffffe2, 28);
66 codes[3] = new HuffmanCode(0xfffffe3, 28);
67 codes[4] = new HuffmanCode(0xfffffe4, 28);
68 codes[5] = new HuffmanCode(0xfffffe5, 28);
69 codes[6] = new HuffmanCode(0xfffffe6, 28);
70 codes[7] = new HuffmanCode(0xfffffe7, 28);
71 codes[8] = new HuffmanCode(0xfffffe8, 28);
72 codes[9] = new HuffmanCode(0xffffea, 24);
73 codes[10] = new HuffmanCode(0x3ffffffc, 30);
74 codes[11] = new HuffmanCode(0xfffffe9, 28);
75 codes[12] = new HuffmanCode(0xfffffea, 28);
76 codes[13] = new HuffmanCode(0x3ffffffd, 30);
77 codes[14] = new HuffmanCode(0xfffffeb, 28);
78 codes[15] = new HuffmanCode(0xfffffec, 28);
79 codes[16] = new HuffmanCode(0xfffffed, 28);
80 codes[17] = new HuffmanCode(0xfffffee, 28);
81 codes[18] = new HuffmanCode(0xfffffef, 28);
82 codes[19] = new HuffmanCode(0xffffff0, 28);
83 codes[20] = new HuffmanCode(0xffffff1, 28);
84 codes[21] = new HuffmanCode(0xffffff2, 28);
85 codes[22] = new HuffmanCode(0x3ffffffe, 30);
86 codes[23] = new HuffmanCode(0xffffff3, 28);
87 codes[24] = new HuffmanCode(0xffffff4, 28);
88 codes[25] = new HuffmanCode(0xffffff5, 28);

Callers

nothing calls this directly

Calls 4

getManagerMethod · 0.95
removeMethod · 0.65
equalsMethod · 0.65
isEmptyMethod · 0.45

Tested by

no test coverage detected