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

Commit

Permalink
Update hyperframe to 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasa committed Jun 28, 2015
1 parent 8763840 commit 5d8b321
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
7 changes: 7 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Release History
===============

dev
---

*Software Updates*

- Updated hyperframe to version 1.1.0.

0.4.0 (2015-06-21)
------------------

Expand Down
2 changes: 1 addition & 1 deletion hyper/packages/hyperframe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
A module for providing a pure-Python HTTP/2 framing layer.
"""
__version__ = '1.0.0'
__version__ = '1.1.0'
15 changes: 9 additions & 6 deletions hyper/packages/hyperframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import collections
import struct

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

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

class Frame(object):
"""
Expand All @@ -31,6 +33,7 @@ class Frame(object):
def __init__(self, stream_id):
self.stream_id = stream_id
self.flags = set()
self.body_len = 0

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

def serialize(self):
body = self.serialize_body()
body_len = len(body)
self.body_len = len(body)

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

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

0 comments on commit 5d8b321

Please sign in to comment.