Skip to content

Commit b3434d1

Browse files
committed
Merge pull request #45 from python-hyper/altsvc-memoryview
Ensure AltSvc's repr works properly.
2 parents c410c4c + 5cad9e9 commit b3434d1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

hyperframe/frame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,12 +710,12 @@ def serialize_body(self):
710710
def parse_body(self, data):
711711
try:
712712
origin_len = struct.unpack("!H", data[0:2])[0]
713-
self.origin = data[2:2+origin_len]
713+
self.origin = data[2:2+origin_len].tobytes()
714714

715715
if len(self.origin) != origin_len:
716716
raise InvalidFrameError("Invalid ALTSVC frame body.")
717717

718-
self.field = data[2+origin_len:]
718+
self.field = data[2+origin_len:].tobytes()
719719
except (struct.error, ValueError):
720720
raise InvalidFrameError("Invalid ALTSVC frame body.")
721721

test/test_frames.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,13 @@ def test_altsvc_frame_without_origin_parses_properly(self):
690690
assert f.body_len == 19
691691
assert f.stream_id == 1
692692

693+
def test_altsvc_frame_without_origin_parses_with_good_repr(self):
694+
f = decode_frame(self.payload_without_origin)
695+
696+
assert repr(f) == (
697+
"AltSvcFrame(Stream: 1; Flags: None): 000068323d223a383030..."
698+
)
699+
693700
def test_altsvc_frame_with_origin_and_stream_serializes_properly(self):
694701
# This frame is not valid, but we allow it to be serialized anyway.
695702
f = AltSvcFrame(stream_id=1)

0 commit comments

Comments
 (0)