diff options
Diffstat (limited to 'libpathod/protocols')
-rw-r--r-- | libpathod/protocols/http.py | 18 | ||||
-rw-r--r-- | libpathod/protocols/http2.py | 4 |
2 files changed, 12 insertions, 10 deletions
diff --git a/libpathod/protocols/http.py b/libpathod/protocols/http.py index 0539b68d..ac6cb374 100644 --- a/libpathod/protocols/http.py +++ b/libpathod/protocols/http.py @@ -1,14 +1,12 @@ -from netlib import tcp, http, wsgi -from netlib.http import http1 -from .. import version, app, language, utils, log +from netlib import tcp, wsgi +from netlib.exceptions import HttpReadDisconnect +from netlib.http import http1, Request +from .. import version, language -class HTTPProtocol: +class HTTPProtocol(object): def __init__(self, pathod_handler): self.pathod_handler = pathod_handler - self.wire_protocol = http1.HTTP1Protocol( - self.pathod_handler - ) def make_error_response(self, reason, body): return language.http.make_error_response(reason, body) @@ -70,4 +68,8 @@ class HTTPProtocol: return self.pathod_handler.handle_http_request, None def read_request(self, lg=None): - return self.wire_protocol.read_request(allow_empty=True) + try: + return http1.read_request(self.pathod_handler.rfile) + except HttpReadDisconnect: + # TODO: This is + return Request("", b"", b"", b"", b"", b"", b"", None, b"") diff --git a/libpathod/protocols/http2.py b/libpathod/protocols/http2.py index f57f56f8..44a51410 100644 --- a/libpathod/protocols/http2.py +++ b/libpathod/protocols/http2.py @@ -5,7 +5,7 @@ class HTTP2Protocol: def __init__(self, pathod_handler): self.pathod_handler = pathod_handler - self.wire_protocol = http2.HTTP2Protocol( + self.wire_protocol = http2.connections.HTTP2Protocol( self.pathod_handler, is_server=True, dump_frames=self.pathod_handler.http2_framedump ) @@ -14,7 +14,7 @@ class HTTP2Protocol: def read_request(self, lg=None): self.wire_protocol.perform_server_connection_preface() - return self.wire_protocol.read_request() + return self.wire_protocol.read_request(self.pathod_handler.rfile) def assemble(self, message): return self.wire_protocol.assemble(message) |