-
Notifications
You must be signed in to change notification settings - Fork 194
Refactor Stream to ensure header blocks are decoded in the correct order #39
Refactor Stream to ensure header blocks are decoded in the correct order #39
Conversation
…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.
@@ -155,18 +181,14 @@ def listlen(list): | |||
w = WindowUpdateFrame(self.stream_id) | |||
w.window_increment = increment | |||
self._data_cb(w) | |||
else: # pragma: no cover |
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.
Don't pragma no cover this, test it. =)
This is a good idea, thanks! Some code review comments inline. =) |
Thanks for the review! Addressed comments, and build is green once more. |
Awesome! Aside from the comment I made in #40, I'm ready to merge this! =) |
Right, the comment was a good suggestion, but |
@@ -12,6 +12,7 @@ | |||
DataFrame, HeadersFrame, SettingsFrame, Frame, WindowUpdateFrame, | |||
GoAwayFrame | |||
) | |||
from .response import HTTP20Response |
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.
Do we need this import?
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.
Nevermind, I'll fix it up. =D
Refactor Stream to ensure header blocks are decoded in the correct order
Thanks! On Mon, Apr 7, 2014 at 11:35 AM, Cory Benfield [email protected]:
|
Previously, incoming frames were placed on per-
Stream
queues, which were read from lazily, i.e. wheneverHTTP20Response.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()
toStream.receive_frame()
, which is executed on theConnection
's event loop.DATA
frame receiving was refactored in a similar way for consistency.