diff options
author | Thomas Kriechbaumer <Kriechi@users.noreply.github.com> | 2016-07-07 21:11:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-07 21:11:55 +0200 |
commit | 7baeac4d67c40a64106aa4633eecb42a588518a1 (patch) | |
tree | bd82ef677253c82f7c157b1d2efb4808f2627388 /test | |
parent | a212ce1f636bf14fdfb7cd7f238626c70bcfacb9 (diff) | |
parent | d962bd4e836856522c101b20e0167c3492d18965 (diff) | |
download | mitmproxy-7baeac4d67c40a64106aa4633eecb42a588518a1.tar.gz mitmproxy-7baeac4d67c40a64106aa4633eecb42a588518a1.tar.bz2 mitmproxy-7baeac4d67c40a64106aa4633eecb42a588518a1.zip |
Merge pull request #1325 from Kriechi/dufferzafar-py3-h2
HTTP/2: Python 3-compatibility
Diffstat (limited to 'test')
-rw-r--r-- | test/mitmproxy/test_protocol_http2.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/test/mitmproxy/test_protocol_http2.py b/test/mitmproxy/test_protocol_http2.py index 2eb0b120..58ffb787 100644 --- a/test/mitmproxy/test_protocol_http2.py +++ b/test/mitmproxy/test_protocol_http2.py @@ -126,7 +126,7 @@ class _Http2TestBase(object): client.wfile.flush() # read CONNECT response - while client.rfile.readline() != "\r\n": + while client.rfile.readline() != b"\r\n": pass client.convert_to_ssl(alpn_protos=[b'h2']) @@ -169,8 +169,8 @@ class TestSimple(_Http2TestBase, _Http2ServerBase): if isinstance(event, h2.events.ConnectionTerminated): return False elif isinstance(event, h2.events.RequestReceived): - assert ('client-foo', 'client-bar-1') in event.headers - assert ('client-foo', 'client-bar-2') in event.headers + assert (b'client-foo', b'client-bar-1') in event.headers + assert (b'client-foo', b'client-bar-2') in event.headers import warnings with warnings.catch_warnings(): @@ -203,7 +203,7 @@ class TestSimple(_Http2TestBase, _Http2ServerBase): (':path', '/'), ('ClIeNt-FoO', 'client-bar-1'), ('ClIeNt-FoO', 'client-bar-2'), - ], body='my request body echoed back to me') + ], body=b'my request body echoed back to me') done = False while not done: @@ -275,7 +275,7 @@ class TestWithBodies(_Http2TestBase, _Http2ServerBase): (':scheme', 'https'), (':path', '/'), ], - body='foobar with request body', + body=b'foobar with request body', ) done = False @@ -538,7 +538,7 @@ class TestMaxConcurrentStreams(_Http2TestBase, _Http2ServerBase): (':status', '200'), ('X-Stream-ID', str(event.stream_id)), ]) - h2_conn.send_data(event.stream_id, b'Stream-ID {}'.format(event.stream_id)) + h2_conn.send_data(event.stream_id, 'Stream-ID {}'.format(event.stream_id).encode()) h2_conn.end_stream(event.stream_id) wfile.write(h2_conn.data_to_send()) wfile.flush() @@ -579,7 +579,7 @@ class TestMaxConcurrentStreams(_Http2TestBase, _Http2ServerBase): assert len(self.master.state.flows) == len(new_streams) for flow in self.master.state.flows: assert flow.response.status_code == 200 - assert "Stream-ID" in flow.response.body + assert b"Stream-ID " in flow.response.body @requires_alpn @@ -598,7 +598,7 @@ class TestConnectionTerminated(_Http2TestBase, _Http2ServerBase): @classmethod def handle_server_event(self, event, h2_conn, rfile, wfile): if isinstance(event, h2.events.RequestReceived): - h2_conn.close_connection(error_code=5, last_stream_id=42, additional_data='foobar') + h2_conn.close_connection(error_code=5, last_stream_id=42, additional_data=b'foobar') wfile.write(h2_conn.data_to_send()) wfile.flush() return True @@ -630,4 +630,4 @@ class TestConnectionTerminated(_Http2TestBase, _Http2ServerBase): assert connection_terminated_event is not None assert connection_terminated_event.error_code == 5 assert connection_terminated_event.last_stream_id == 42 - assert connection_terminated_event.additional_data == 'foobar' + assert connection_terminated_event.additional_data == b'foobar' |