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

Commit 5d8b321

Browse files
committed
Update hyperframe to 1.1.0
1 parent 8763840 commit 5d8b321

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

HISTORY.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Release History
22
===============
33

4+
dev
5+
---
6+
7+
*Software Updates*
8+
9+
- Updated hyperframe to version 1.1.0.
10+
411
0.4.0 (2015-06-21)
512
------------------
613

hyper/packages/hyperframe/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
66
A module for providing a pure-Python HTTP/2 framing layer.
77
"""
8-
__version__ = '1.0.0'
8+
__version__ = '1.1.0'

hyper/packages/hyperframe/frame.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
import collections
1111
import struct
1212

13-
# The maximum length of a frame. Some frames have shorter maximum lengths.
13+
# The maximum initial length of a frame. Some frames have shorter maximum lengths.
1414
FRAME_MAX_LEN = (2 ** 14) - 1
1515

16+
# The maximum allowed length of a frame.
17+
FRAME_MAX_ALLOWED_LEN = (2 ** 24) - 1
1618

1719
class Frame(object):
1820
"""
@@ -31,6 +33,7 @@ class Frame(object):
3133
def __init__(self, stream_id):
3234
self.stream_id = stream_id
3335
self.flags = set()
36+
self.body_len = 0
3437

3538
if self.stream_association == 'has-stream' and not self.stream_id:
3639
raise ValueError('Stream ID must be non-zero')
@@ -40,7 +43,7 @@ def __init__(self, stream_id):
4043
@staticmethod
4144
def parse_frame_header(header):
4245
"""
43-
Takes an 9-byte frame header and returns a tuple of the appropriate
46+
Takes a 9-byte frame header and returns a tuple of the appropriate
4447
Frame object and the length that needs to be read from the socket.
4548
"""
4649
fields = struct.unpack("!HBBBL", header)
@@ -63,7 +66,7 @@ def parse_flags(self, flag_byte):
6366

6467
def serialize(self):
6568
body = self.serialize_body()
66-
body_len = len(body)
69+
self.body_len = len(body)
6770

6871
# Build the common frame header.
6972
# First, get the flags.
@@ -75,8 +78,8 @@ def serialize(self):
7578

7679
header = struct.pack(
7780
"!HBBBL",
78-
body_len & 0xFFFF00, # Length is spread over top 24 bits
79-
body_len & 0x0000FF,
81+
(self.body_len & 0xFFFF00) >> 8, # Length is spread over top 24 bits
82+
self.body_len & 0x0000FF,
8083
self.type,
8184
flags,
8285
self.stream_id & 0x7FFFFFFF # Stream ID is 32 bits.
@@ -408,7 +411,7 @@ class HeadersFrame(Padding, Priority, Frame):
408411
(remote)" states.
409412
410413
The HeadersFrame class is actually basically a data frame in this
411-
implementation, becuase of the requirement to control the sizes of frames.
414+
implementation, because of the requirement to control the sizes of frames.
412415
A header block fragment that doesn't fit in an entire HEADERS frame needs
413416
to be followed with CONTINUATION frames. From the perspective of the frame
414417
building code the header block is an opaque data segment.

0 commit comments

Comments
 (0)