Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Refactor Stream to ensure header blocks are decoded in the correct order #39

Merged
merged 3 commits into from
Apr 7, 2014

Conversation

alekstorm
Copy link
Contributor

Previously, incoming frames were placed on per-Stream queues, which were read from lazily, i.e. whenever HTTP20Response.getheaders() or .read() were called. However, the HPACK algorithm depends on header blocks being encoded/decoded in the same order on both sides of the connection; otherwise, the codec states on each peer will get out of sync.

This PR rearranges header decoding by moving it from Stream.getresponse() to Stream.receive_frame(), which is executed on the Connection's event loop. DATA frame receiving was refactored in a similar way for consistency.

…der:

Previously, incoming frames were placed on per-Stream queues, which were
read from lazily, i.e. whenever HTTP20Response.getheaders() or .read()
were called. However, the HPACK algorithm depends on header blocks being
encoded/decoded in the same order on both sides of the connection;
otherwise, the codec states on each peer will get out of sync.

This commit rearranges header decoding by moving it from
Stream.getresponse() to Stream.receive_frame(), which is executed on
the Connection's event loop. DATA frame receiving was refactored in a
similar way for consistency.
@alekstorm alekstorm mentioned this pull request Apr 7, 2014
@@ -155,18 +181,14 @@ def listlen(list):
w = WindowUpdateFrame(self.stream_id)
w.window_increment = increment
self._data_cb(w)
else: # pragma: no cover
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't pragma no cover this, test it. =)

@Lukasa
Copy link
Member

Lukasa commented Apr 7, 2014

This is a good idea, thanks! Some code review comments inline. =)

@alekstorm
Copy link
Contributor Author

Thanks for the review! Addressed comments, and build is green once more.

@Lukasa
Copy link
Member

Lukasa commented Apr 7, 2014

Awesome! Aside from the comment I made in #40, I'm ready to merge this! =)

@alekstorm
Copy link
Contributor Author

Right, the comment was a good suggestion, but extract_from_key_value_set only exists in the server-push branch, so I think this is good to go.

@@ -12,6 +12,7 @@
DataFrame, HeadersFrame, SettingsFrame, Frame, WindowUpdateFrame,
GoAwayFrame
)
from .response import HTTP20Response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this import?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I'll fix it up. =D

Lukasa added a commit that referenced this pull request Apr 7, 2014
Refactor Stream to ensure header blocks are decoded in the correct order
@Lukasa Lukasa merged commit 5267f88 into python-hyper:development Apr 7, 2014
@alekstorm
Copy link
Contributor Author

Thanks!

On Mon, Apr 7, 2014 at 11:35 AM, Cory Benfield notifications@github.comwrote:

Merged #39 #39.

Reply to this email directly or view it on GitHubhttps://github.com//pull/39
.

@alekstorm alekstorm deleted the header-decoding-order branch April 7, 2014 18:43
Lukasa added a commit that referenced this pull request Apr 7, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants