aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/pathod.py
diff options
context:
space:
mode:
Diffstat (limited to 'libpathod/pathod.py')
-rw-r--r--libpathod/pathod.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index 4b94ec91..6478fe4f 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -6,7 +6,8 @@ import threading
import urllib
from netlib import tcp, http, certutils, websockets
-from netlib.http import http1, http2
+from netlib.exceptions import HttpException, HttpReadDisconnect
+from netlib.http import ALPN_PROTO_HTTP1, ALPN_PROTO_H2
from . import version, app, language, utils, log, protocols
import language.http
@@ -40,7 +41,7 @@ class SSLOptions(object):
ssl_options=tcp.SSL_DEFAULT_OPTIONS,
ciphers=None,
certs=None,
- alpn_select=http2.HTTP2Protocol.ALPN_PROTO_H2,
+ alpn_select=ALPN_PROTO_H2,
):
self.confdir = confdir
self.cn = cn
@@ -124,15 +125,14 @@ class PathodHandler(tcp.BaseHandler):
"""
with logger.ctx() as lg:
try:
- req = self.protocol.read_request()
- except http.HttpError as s:
+ 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 isinstance(req, http.EmptyRequest):
- return None, None
-
if req.method == 'CONNECT':
return self.protocol.handle_http_connect([req.host, req.port, req.httpversion], lg)
@@ -259,7 +259,7 @@ class PathodHandler(tcp.BaseHandler):
return
alp = self.get_alpn_proto_negotiated()
- if alp == http2.HTTP2Protocol.ALPN_PROTO_H2:
+ if alp == ALPN_PROTO_H2:
self.protocol = protocols.http2.HTTP2Protocol(self)
self.use_http2 = True