Skip to content

Commit

Permalink
Merge pull request #79 from chhsiao90/stream-id-ignore-fist-bit
Browse files Browse the repository at this point in the history
Ignored first bit of stream identity when parsing
  • Loading branch information
Lukasa committed Feb 9, 2017
2 parents 1895404 + 1aa815b commit ae006e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hyperframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def parse_frame_header(header):
length = (fields[0] << 8) + fields[1]
type = fields[2]
flags = fields[3]
stream_id = fields[4]
stream_id = fields[4] & 0x7FFFFFFF

if type not in FRAMES:
raise UnknownFrameError(type, length)
Expand Down
6 changes: 6 additions & 0 deletions test/test_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def test_parse_frame_header_unknown_type(self):
"length 89 bytes"
)

def test_parse_frame_header_ignore_first_bit_of_stream_id(self):
s = b'\x00\x00\x00\x06\x01\x80\x00\x00\x00'
f, _ = Frame.parse_frame_header(s)

assert f.stream_id == 0

def test_repr(self, monkeypatch):
f = Frame(stream_id=0)
monkeypatch.setattr(Frame, "serialize_body", lambda _: b"body")
Expand Down

0 comments on commit ae006e3

Please sign in to comment.