diff options
| -rw-r--r-- | netlib/http/http1/protocol.py | 6 | ||||
| -rw-r--r-- | netlib/http/http2/protocol.py | 11 | ||||
| -rw-r--r-- | netlib/http/semantics.py | 9 | ||||
| -rw-r--r-- | test/http/http1/test_protocol.py | 5 | ||||
| -rw-r--r-- | test/http/http2/test_protocol.py | 5 | ||||
| -rw-r--r-- | test/websockets/test_websockets.py | 2 | 
6 files changed, 20 insertions, 18 deletions
| diff --git a/netlib/http/http1/protocol.py b/netlib/http/http1/protocol.py index 107a48d1..6b4489fb 100644 --- a/netlib/http/http1/protocol.py +++ b/netlib/http/http1/protocol.py @@ -136,8 +136,8 @@ class HTTP1Protocol(semantics.ProtocolMixin):      def read_response(          self, -        request, -        body_size_limit, +        request_method, +        body_size_limit=None,          include_body=True,      ):          """ @@ -175,7 +175,7 @@ class HTTP1Protocol(semantics.ProtocolMixin):              body = self.read_http_body(                  headers,                  body_size_limit, -                request.method, +                request_method,                  code,                  False              ) diff --git a/netlib/http/http2/protocol.py b/netlib/http/http2/protocol.py index 1d6e0168..b6a147d4 100644 --- a/netlib/http/http2/protocol.py +++ b/netlib/http/http2/protocol.py @@ -68,6 +68,9 @@ class HTTP2Protocol(semantics.ProtocolMixin):          body_size_limit=None,          allow_empty=False,      ): +        if body_size_limit is not None: +            raise NotImplementedError() +          self.perform_connection_preface()          timestamp_start = time.time() @@ -130,10 +133,14 @@ class HTTP2Protocol(semantics.ProtocolMixin):      def read_response(          self, -        request='', +        request_method='',          body_size_limit=None,          include_body=True, +        stream_id=None,      ): +        if body_size_limit is not None: +            raise NotImplementedError() +          self.perform_connection_preface()          timestamp_start = time.time() @@ -141,7 +148,7 @@ class HTTP2Protocol(semantics.ProtocolMixin):              self.tcp_handler.rfile.reset_timestamps()          stream_id, headers, body = self._receive_transmission( -            stream_id=request.stream_id, +            stream_id=stream_id,              include_body=include_body,          ) diff --git a/netlib/http/semantics.py b/netlib/http/semantics.py index e388a344..2b960483 100644 --- a/netlib/http/semantics.py +++ b/netlib/http/semantics.py @@ -345,10 +345,9 @@ class EmptyRequest(Request):          host="",          port="",          path="", -        httpversion=None, +        httpversion=(0, 0),          headers=None, -        body="", -        stream_id=None +        body=""      ):          super(EmptyRequest, self).__init__(              form_in=form_in, @@ -357,12 +356,10 @@ class EmptyRequest(Request):              host=host,              port=port,              path=path, -            httpversion=(httpversion or (0, 0)), +            httpversion=httpversion,              headers=(headers or odict.ODictCaseless()),              body=body,          ) -        if stream_id: -            self.stream_id = stream_id  class Response(object): diff --git a/test/http/http1/test_protocol.py b/test/http/http1/test_protocol.py index 31bf7dab..6704647f 100644 --- a/test/http/http1/test_protocol.py +++ b/test/http/http1/test_protocol.py @@ -376,9 +376,8 @@ class TestReadRequest(object):  class TestReadResponse(object):      def tst(self, data, method, body_size_limit, include_body=True):          data = textwrap.dedent(data) -        request = http.EmptyRequest(method=method)          return mock_protocol(data).read_response( -            request, body_size_limit, include_body=include_body +            method, body_size_limit, include_body=include_body          )      def test_errors(self): @@ -458,7 +457,7 @@ class TestReadResponseNoContentLength(tservers.ServerTestBase):      def test_no_content_length(self):          c = tcp.TCPClient(("127.0.0.1", self.port))          c.connect() -        resp = HTTP1Protocol(c).read_response(http.EmptyRequest(method="GET"), None) +        resp = HTTP1Protocol(c).read_response("GET", None)          assert resp.body == "bar\r\n\r\n" diff --git a/test/http/http2/test_protocol.py b/test/http/http2/test_protocol.py index 92fa109c..8810894f 100644 --- a/test/http/http2/test_protocol.py +++ b/test/http/http2/test_protocol.py @@ -410,9 +410,8 @@ class TestReadResponse(tservers.ServerTestBase):          protocol = HTTP2Protocol(c)          protocol.connection_preface_performed = True -        resp = protocol.read_response(http.EmptyRequest(stream_id=42)) +        resp = protocol.read_response(stream_id=42) -        assert resp.stream_id == 42          assert resp.httpversion == (2, 0)          assert resp.status_code == 200          assert resp.msg == "" @@ -437,7 +436,7 @@ class TestReadEmptyResponse(tservers.ServerTestBase):          protocol = HTTP2Protocol(c)          protocol.connection_preface_performed = True -        resp = protocol.read_response(http.EmptyRequest(stream_id=42)) +        resp = protocol.read_response(stream_id=42)          assert resp.stream_id == 42          assert resp.httpversion == (2, 0) diff --git a/test/websockets/test_websockets.py b/test/websockets/test_websockets.py index 5f27c128..be87b20a 100644 --- a/test/websockets/test_websockets.py +++ b/test/websockets/test_websockets.py @@ -70,7 +70,7 @@ class WebSocketsClient(tcp.TCPClient):          self.wfile.write(headers.format() + "\r\n")          self.wfile.flush() -        resp = http1_protocol.read_response(http.EmptyRequest(method="GET"), None) +        resp = http1_protocol.read_response("GET", None)          server_nonce = self.protocol.check_server_handshake(resp.headers)          if not server_nonce == self.protocol.create_server_nonce( | 
