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

Commit

Permalink
Per-frame compression is gone.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasa committed Jun 20, 2014
1 parent a7c42db commit f4cb68e
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 59 deletions.
1 change: 0 additions & 1 deletion hyper/http20/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ def connect(self):
sock.send(b'PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n')
f = SettingsFrame(0)
f.settings[SettingsFrame.ENABLE_PUSH] = int(self._enable_push)
f.settings[SettingsFrame.COMPRESS_DATA] = 1
self._send_cb(f)

# The server will also send an initial settings frame, so get it.
Expand Down
5 changes: 0 additions & 5 deletions hyper/http20/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ class DataFrame(Padding, Frame):
('END_STREAM', 0x01),
('END_SEGMENT', 0x02),
('PADDED', 0x08),
('COMPRESSED', 0x20),
]

type = 0x0
Expand All @@ -177,10 +176,6 @@ def parse_body(self, data):
padding_data_length = self.parse_padding_data(data)
self.data = data[padding_data_length:len(data)-self.total_padding].tobytes()

@property
def has_compressed_data(self):
return 'COMPRESSED' in self.flags


class PriorityFrame(Priority, Frame):
"""
Expand Down
10 changes: 2 additions & 8 deletions hyper/http20/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,8 @@ def receive_frame(self, frame):
size = len(frame.data) + frame.total_padding
increment = self._in_window_manager._handle_frame(size)

# Append the data to the buffer. If the data is compressed,
# uncompress it.
if frame.has_compressed_data:
new_data = zlib.decompress(frame.data, 16 + zlib.MAX_WBITS)
else:
new_data = frame.data

self.data.append(new_data)
# Append the data to the buffer.
self.data.append(frame.data)

if increment and not self._remote_closed:
w = WindowUpdateFrame(self.stream_id)
Expand Down
47 changes: 3 additions & 44 deletions test/test_hyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_data_frame_has_correct_flags(self):
f = DataFrame(1)
flags = f.parse_flags(0xFF)
assert flags == set([
'END_STREAM', 'END_SEGMENT', 'PADDED', 'COMPRESSED',
'END_STREAM', 'END_SEGMENT', 'PADDED'
])

def test_data_frame_serializes_properly(self):
Expand Down Expand Up @@ -100,16 +100,6 @@ def test_data_frame_comes_on_a_stream(self):
with pytest.raises(ValueError):
DataFrame(0)

def test_data_frame_is_compressed(self):
f1 = DataFrame(1)
f1.flags.add('COMPRESSED')

f2 = DataFrame(1)
f2.flags = set()

assert f1.has_compressed_data
assert not f2.has_compressed_data


class TestPriorityFrame(object):
payload = b'\x00\x05\x02\x00\x00\x00\x00\x01\x80\x00\x00\x04\x40'
Expand Down Expand Up @@ -178,20 +168,18 @@ def test_rst_stream_frame_must_have_body_length_four(self):

class TestSettingsFrame(object):
serialized = (
b'\x00\x19\x04\x01\x00\x00\x00\x00' + # Frame header
b'\x00\x14\x04\x01\x00\x00\x00\x00' + # Frame header
b'\x01\x00\x00\x10\x00' + # HEADER_TABLE_SIZE
b'\x02\x00\x00\x00\x00' + # ENABLE_PUSH
b'\x03\x00\x00\x00\x64' + # MAX_CONCURRENT_STREAMS
b'\x04\x00\x00\xFF\xFF' + # INITIAL_WINDOW_SIZE
b'\x05\x00\x00\x00\x01' # COMPRESS_DATA
b'\x04\x00\x00\xFF\xFF' # INITIAL_WINDOW_SIZE
)

settings = {
SettingsFrame.HEADER_TABLE_SIZE: 4096,
SettingsFrame.ENABLE_PUSH: 0,
SettingsFrame.MAX_CONCURRENT_STREAMS: 100,
SettingsFrame.INITIAL_WINDOW_SIZE: 65535,
SettingsFrame.COMPRESS_DATA: 1,
}

def test_settings_frame_has_only_one_flag(self):
Expand Down Expand Up @@ -1742,35 +1730,6 @@ def inner():
assert len(out_frames) == 1
assert s.state == STATE_CLOSED

def test_compressed_stream_reading_works(self):
out_frames = []
in_frames = []

def send_cb(frame, tolerate_peer_gone=False):
out_frames.append(frame)

def recv_cb(s):
def inner():
s.receive_frame(in_frames.pop(0))
return inner

s = Stream(1, send_cb, None, None, None, None, FlowControlManager(65535))
s._recv_cb = recv_cb(s)
s.state = STATE_HALF_CLOSED_LOCAL

# Provide a data frame to read.
f = DataFrame(1)
c = zlib_compressobj(wbits=24)
f.data = c.compress(b'hi there!')
f.data += c.flush()
f.flags.add('END_STREAM')
f.flags.add('COMPRESSED')
in_frames.append(f)

data = s._read()
assert data == b'hi there!'
assert len(out_frames) == 0

def test_receive_unexpected_frame(self):
# SETTINGS frames are never defined on streams, so send one of those.
s = Stream(1, None, None, None, None, None, None)
Expand Down
1 change: 0 additions & 1 deletion test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def socket_handler(listener):
assert f.stream_id == 0
assert f.settings == {
SettingsFrame.ENABLE_PUSH: 0,
SettingsFrame.COMPRESS_DATA: 1,
}

self.tear_down()
Expand Down

0 comments on commit f4cb68e

Please sign in to comment.