diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index c67fdb75d..d616761e8 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -14,7 +14,7 @@ import six from netlib import tcp, http, certutils, websockets, socks from netlib.exceptions import HttpException -from netlib.http import http1, http2, ALPN_PROTO_HTTP1 +from netlib.http import http1, http2 import language.http import language.websockets @@ -289,7 +289,7 @@ class Pathoc(tcp.TCPClient): self.sslinfo = None if self.ssl: try: - alpn_protos = [ALPN_PROTO_HTTP1] + alpn_protos = [http.ALPN_PROTO_HTTP1] if self.use_http2: alpn_protos.append(http.ALPN_PROTO_H2) diff --git a/libpathod/pathod.py b/libpathod/pathod.py index 052bb379f..6478fe4f3 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -6,7 +6,7 @@ import threading import urllib from netlib import tcp, http, certutils, websockets -from netlib.exceptions import HttpException +from netlib.exceptions import HttpException, HttpReadDisconnect from netlib.http import ALPN_PROTO_HTTP1, ALPN_PROTO_H2 from . import version, app, language, utils, log, protocols @@ -126,14 +126,13 @@ class PathodHandler(tcp.BaseHandler): with logger.ctx() as lg: try: req = self.protocol.read_request(self.rfile) + except HttpReadDisconnect: + return None, None except HttpException as s: s = str(s) lg(s) return None, dict(type="error", msg=s) - if req.method == b"" and req.form_in == "": - return None, None - if req.method == 'CONNECT': return self.protocol.handle_http_connect([req.host, req.port, req.httpversion], lg) diff --git a/libpathod/protocols/http.py b/libpathod/protocols/http.py index ac6cb374a..531854d6a 100644 --- a/libpathod/protocols/http.py +++ b/libpathod/protocols/http.py @@ -68,8 +68,4 @@ class HTTPProtocol(object): return self.pathod_handler.handle_http_request, None def read_request(self, lg=None): - try: - return http1.read_request(self.pathod_handler.rfile) - except HttpReadDisconnect: - # TODO: This is - return Request("", b"", b"", b"", b"", b"", b"", None, b"") + return http1.read_request(self.pathod_handler.rfile) diff --git a/libpathod/protocols/http2.py b/libpathod/protocols/http2.py index 44a51410b..a098a14e6 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.connections.HTTP2Protocol( + self.wire_protocol = http2.HTTP2Protocol( self.pathod_handler, is_server=True, dump_frames=self.pathod_handler.http2_framedump ) diff --git a/test/tutils.py b/test/tutils.py index ff71387a6..a728e8529 100644 --- a/test/tutils.py +++ b/test/tutils.py @@ -63,7 +63,7 @@ class DaemonTests(object): def getpath(self, path, params=None): scheme = "https" if self.ssl else "http" resp = requests.get( - "%s://127.0.0.1:%s/%s" % ( + "%s://localhost:%s/%s" % ( scheme, self.d.port, path