From a2bf19125a92a4fa372708cf2cda7887ab62ac76 Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Sat, 11 Jul 2015 23:47:43 +0200 Subject: refactor protocol-related pathod methods --- libpathod/protocols/http2.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 libpathod/protocols/http2.py (limited to 'libpathod/protocols/http2.py') diff --git a/libpathod/protocols/http2.py b/libpathod/protocols/http2.py new file mode 100644 index 00000000..29c4e556 --- /dev/null +++ b/libpathod/protocols/http2.py @@ -0,0 +1,20 @@ +from netlib import tcp, http, http2, wsgi, certutils, websockets, odict +from .. import version, app, language, utils, log + +class HTTP2Protocol: + + def __init__(self, pathod_handler): + self.pathod_handler = pathod_handler + self.wire_protocol = http2.HTTP2Protocol( + self.pathod_handler, is_server=True, dump_frames=self.pathod_handler.http2_framedump + ) + + def make_error_response(self, reason, body): + return language.http2.make_error_response(reason, body) + + def read_request(self): + self.wire_protocol.perform_server_connection_preface() + return self.wire_protocol.read_request() + + def create_response(self, code, stream_id, headers, body): + return self.wire_protocol.create_response(code, stream_id, headers, body) -- cgit v1.2.3