QpackUtil Class — netty Architecture
Architecture documentation for the QpackUtil class in QpackUtil.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD be173d53_8b5e_e8c7_536e_bb5840ee634a["QpackUtil"] 5dac591f_ee27_c370_6f61_c515e9ecef76["QpackUtil.java"] be173d53_8b5e_e8c7_536e_bb5840ee634a -->|defined in| 5dac591f_ee27_c370_6f61_c515e9ecef76 9903ae44_ea07_e33b_fd91_b479a8e47850["encodePrefixedInteger()"] be173d53_8b5e_e8c7_536e_bb5840ee634a -->|method| 9903ae44_ea07_e33b_fd91_b479a8e47850 d5455c89_7832_04d6_d655_ef21269b54e3["decodePrefixedIntegerAsInt()"] be173d53_8b5e_e8c7_536e_bb5840ee634a -->|method| d5455c89_7832_04d6_d655_ef21269b54e3 dd44b3be_9aea_6528_ede1_8df4ad1c9b86["toIntOrThrow()"] be173d53_8b5e_e8c7_536e_bb5840ee634a -->|method| dd44b3be_9aea_6528_ede1_8df4ad1c9b86 7eae73ee_1f1f_149c_78a1_09413dd2bb87["decodePrefixedInteger()"] be173d53_8b5e_e8c7_536e_bb5840ee634a -->|method| 7eae73ee_1f1f_149c_78a1_09413dd2bb87 34aa2c52_2fbc_fb67_caed_bc14e072c842["firstByteEquals()"] be173d53_8b5e_e8c7_536e_bb5840ee634a -->|method| 34aa2c52_2fbc_fb67_caed_bc14e072c842 36a18351_4778_e6c8_69fb_99bfe8984c70["equalsConstantTime()"] be173d53_8b5e_e8c7_536e_bb5840ee634a -->|method| 36a18351_4778_e6c8_69fb_99bfe8984c70 94545e60_3e10_4c58_8594_97ebb70f58fa["equalsVariableTime()"] be173d53_8b5e_e8c7_536e_bb5840ee634a -->|method| 94545e60_3e10_4c58_8594_97ebb70f58fa 7072de6d_0627_5069_132d_2989eae84356["maxEntries()"] be173d53_8b5e_e8c7_536e_bb5840ee634a -->|method| 7072de6d_0627_5069_132d_2989eae84356 18a0070b_12b0_b236_27d4_5167b9beeedf["QpackUtil()"] be173d53_8b5e_e8c7_536e_bb5840ee634a -->|method| 18a0070b_12b0_b236_27d4_5167b9beeedf
Relationship Graph
Source Code
codec-http3/src/main/java/io/netty/handler/codec/http3/QpackUtil.java lines 26–468
final class QpackUtil {
private static final QpackException PREFIXED_INTEGER_TOO_LONG =
QpackException.newStatic(QpackDecoder.class, "toIntOrThrow(...)",
"QPACK - invalid prefixed integer");
/**
* Encode integer according to
* <a href="https://tools.ietf.org/html/rfc7541#section-5.1">Section 5.1</a>.
*/
static void encodePrefixedInteger(ByteBuf out, byte mask, int prefixLength, long toEncode) {
checkInRange(toEncode, 0, MAX_UNSIGNED_INT, "toEncode");
int nbits = (1 << prefixLength) - 1;
if (toEncode < nbits) {
out.writeByte((byte) (mask | toEncode));
} else {
out.writeByte((byte) (mask | nbits));
long remainder = toEncode - nbits;
while (remainder > 128) {
byte next = (byte) ((remainder % 128) | 0x80);
out.writeByte(next);
remainder = remainder / 128;
}
out.writeByte((byte) remainder);
}
}
/**
* Decode the integer or return {@code -1} if not enough bytes are readable.
* This method increases the readerIndex when the integer could be decoded.
*
* @param in the input {@link ByteBuf}
* @param prefixLength the prefix length
* @return the integer or {@code -1} if not enough readable bytes are in the {@link ByteBuf).
*/
static int decodePrefixedIntegerAsInt(ByteBuf in, int prefixLength) throws QpackException {
return toIntOrThrow(decodePrefixedInteger(in, prefixLength));
}
/**
* Converts the passed {@code aLong} to an {@code int} if the value can fit an {@code int}, otherwise throws a
* {@link QpackException}.
*
* @param aLong to convert.
* @throws QpackException If the value does not fit an {@code int}.
*/
static int toIntOrThrow(long aLong) throws QpackException {
if ((int) aLong != aLong) {
throw PREFIXED_INTEGER_TOO_LONG;
}
return (int) aLong;
}
/**
* Decode the integer or return {@code -1} if not enough bytes are readable.
* This method increases the readerIndex when the integer could be decoded.
*
* @param in the input {@link ByteBuf}
* @param prefixLength the prefix length
* @return the integer or {@code -1} if not enough readable bytes are in the {@link ByteBuf).
*/
static long decodePrefixedInteger(ByteBuf in, int prefixLength) {
int readerIndex = in.readerIndex();
int writerIndex = in.writerIndex();
if (readerIndex == writerIndex) {
return -1;
}
int nbits = (1 << prefixLength) - 1;
int first = in.readByte() & nbits;
if (first < nbits) {
return first;
}
int idx = readerIndex + 1;
long i = first;
int factor = 0;
byte next;
do {
if (idx == writerIndex) {
in.readerIndex(readerIndex);
return -1;
Source
Frequently Asked Questions
What is the QpackUtil class?
QpackUtil is a class in the netty codebase, defined in codec-http3/src/main/java/io/netty/handler/codec/http3/QpackUtil.java.
Where is QpackUtil defined?
QpackUtil is defined in codec-http3/src/main/java/io/netty/handler/codec/http3/QpackUtil.java at line 26.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free