diff options
| author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-07-16 22:50:24 +0200 |
|---|---|---|
| committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-07-22 15:30:51 +0200 |
| commit | 230c16122b06f5c6af60e6ddc2d8e2e83cd75273 (patch) | |
| tree | 161224f301e7f83e17334dd43a30c1fa2fc9036c | |
| parent | bab6cbff1e5444aea72a188d57812130c375e0f0 (diff) | |
| download | mitmproxy-230c16122b06f5c6af60e6ddc2d8e2e83cd75273.tar.gz mitmproxy-230c16122b06f5c6af60e6ddc2d8e2e83cd75273.tar.bz2 mitmproxy-230c16122b06f5c6af60e6ddc2d8e2e83cd75273.zip | |
change HTTP2 interface to match HTTP1
| -rw-r--r-- | netlib/http/http2/protocol.py | 6 | ||||
| -rw-r--r-- | test/http/http2/test_protocol.py | 20 |
2 files changed, 15 insertions, 11 deletions
diff --git a/netlib/http/http2/protocol.py b/netlib/http/http2/protocol.py index 8e5f5429..0d6eac85 100644 --- a/netlib/http/http2/protocol.py +++ b/netlib/http/http2/protocol.py @@ -2,7 +2,7 @@ from __future__ import (absolute_import, print_function, division) import itertools from hpack.hpack import Encoder, Decoder -from .. import utils +from netlib import http, utils from . import frame @@ -186,9 +186,9 @@ class HTTP2Protocol(object): self._create_headers(headers, stream_id, end_stream=(body is None)), self._create_body(body, stream_id))) - def read_response(self): + def read_response(self, *args): stream_id_, headers, body = self._receive_transmission() - return headers[':status'], headers, body + return http.Response("HTTP/2", headers[':status'], "", headers, body) def read_request(self): return self._receive_transmission() diff --git a/test/http/http2/test_protocol.py b/test/http/http2/test_protocol.py index f607860e..403a2589 100644 --- a/test/http/http2/test_protocol.py +++ b/test/http/http2/test_protocol.py @@ -251,11 +251,13 @@ class TestReadResponse(tservers.ServerTestBase): c.convert_to_ssl() protocol = http2.HTTP2Protocol(c) - status, headers, body = protocol.read_response() + resp = protocol.read_response() - assert headers == {':status': '200', 'etag': 'foobar'} - assert status == "200" - assert body == b'foobar' + assert resp.httpversion == "HTTP/2" + assert resp.status_code == "200" + assert resp.msg == "" + assert resp.headers == {':status': '200', 'etag': 'foobar'} + assert resp.content == b'foobar' class TestReadEmptyResponse(tservers.ServerTestBase): @@ -274,11 +276,13 @@ class TestReadEmptyResponse(tservers.ServerTestBase): c.convert_to_ssl() protocol = http2.HTTP2Protocol(c) - status, headers, body = protocol.read_response() + resp = protocol.read_response() - assert headers == {':status': '200', 'etag': 'foobar'} - assert status == "200" - assert body == b'' + assert resp.httpversion == "HTTP/2" + assert resp.status_code == "200" + assert resp.msg == "" + assert resp.headers == {':status': '200', 'etag': 'foobar'} + assert resp.content == b'' class TestReadRequest(tservers.ServerTestBase): |
