Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoder:encodeHeader() seems to have an issue for Static table entries with values? #34

Open
surendarchandra opened this issue Jan 14, 2020 · 0 comments

Comments

@surendarchandra
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant