hpack
hpack copied to clipboard
Encoder:encodeHeader() seems to have an issue for Static table entries with values?
New to Hpack. Consider hpack/hpack/src/main/java/com/twitter/hpack/Encoder.java: encodeHeader() (starting at line 69)
Consider the input name="content-length", value = "1000" and sensitive == false
We fall through checks in line 72 and 79. Assume we have capacity:
Line 99: HeaderEntry headerField = getEntry("content-length", "1000")
// as byte arrays
// Assume that it is not yet in dynamic array and so headerField == null
Line 105: int staticTableIndex = StaticTable.getIndex("content-length", "1000");
In StaticTable.java: getIndex returns something not -1 because it found this name
For the loop in Line 133:
Entry = HeaderField("content-length", EMPTY)
So, line 138 will never match:
if (HpackUtil.equals(value, entry.value)) {
return index;
}
The problem is not with HpackUtil.equals per se because if it did match EMPTY against "1000", then we need to encode "1000".
In Encoder.java:
if (staticTableIndex != -1) {
// Section 6.1. Indexed Header Field Representation
encodeInteger(out, 0x80, 7, staticTableIndex);
}
We need to encodeLiteral of the value "1000" and a encoderInteger of the Index. What am I missing? Thanks