-
Notifications
You must be signed in to change notification settings - Fork 3.9k
okhttp: fix HPACK reader bug #4276
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
Conversation
@ejona86 I locally ran the OkHttp 2.7 tests (https://github.com/square/okhttp/blob/okhttp_27/okhttp-tests/src/test/java/com/squareup/okhttp/internal/framed/HpackTest.java) on this change, and also added a new test case which verifies the fix for this bug. It seems like it might be time to add (at least) these tests to our forked codebase; what do you think? |
e07b181
to
e5df51b
Compare
e5df51b
to
5980890
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 commits is great
Backport of the first commit of #4276.
Could this be merged? I'd like it in master before doing the release with the backport. |
0c32dfb
to
8453a59
Compare
Fixed the third commit (needed bazel build file update for new path), will merge on green |
This fixes #4261.
Our OkHttp HPACK decoder was improperly tossing out the already-parsed header fields when it resized the dynamic table. From the HPACK RFC section 3.1:
This bug appears to have also been present on the OkHttp 2.7 upstream branch.
This was caught in #4261 by interop with nginx, which was setting the max dynamic table size to 0. When considering adding an item to the table and finding that item exceeds the max dynamic table size,
OkHttp clears the dynamic table. This is the correct behavior, but it was also deleting the already processed header fields. The HTTP status code was among the fields that was erroneously thrown away, triggering the exception in #4261.
The only substantive change in this PR is the deletion of line 167 (
headerList.clear()
) in theclearDynamicTable()
method. The other changes are just two variable renames to make it clear that the values tracked in the dynamic table are not the same as the already-processed header values to return to the application inheaderList
.