aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol2/root_context.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-08-17 19:20:28 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-08-17 19:20:28 +0200
commit99129ab5a15bc4708eda80e4f56b46bb0f1efa86 (patch)
tree661d6eaac3cdc47d2f436df9e8defb73e7a75880 /libmproxy/protocol2/root_context.py
parenta2b85048892626e6834df06e9022498814724636 (diff)
parent38c456bb627c4570e0ed983229ec8ef2f120a4b6 (diff)
downloadmitmproxy-99129ab5a15bc4708eda80e4f56b46bb0f1efa86.tar.gz
mitmproxy-99129ab5a15bc4708eda80e4f56b46bb0f1efa86.tar.bz2
mitmproxy-99129ab5a15bc4708eda80e4f56b46bb0f1efa86.zip
Merge remote-tracking branch 'Kriechi/proxy-refactor' into proxy-refactor
Conflicts: libmproxy/protocol2/http.py
Diffstat (limited to 'libmproxy/protocol2/root_context.py')
-rw-r--r--libmproxy/protocol2/root_context.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/libmproxy/protocol2/root_context.py b/libmproxy/protocol2/root_context.py
index f369fd48..6ba6ca9a 100644
--- a/libmproxy/protocol2/root_context.py
+++ b/libmproxy/protocol2/root_context.py
@@ -3,7 +3,7 @@ from __future__ import (absolute_import, print_function, division)
from .messages import Kill
from .rawtcp import RawTcpLayer
from .tls import TlsLayer
-from .http import HttpLayer
+from .http import Http1Layer, Http2Layer, HttpLayer
class RootContext(object):
@@ -36,13 +36,17 @@ class RootContext(object):
d[2] in ('\x00', '\x01', '\x02', '\x03')
)
+ # TODO: build is_http2_magic check here, maybe this is an easy way to detect h2c
+
if not d:
return iter([])
if is_tls_client_hello:
return TlsLayer(top_layer, True, True)
- elif isinstance(top_layer, TlsLayer) and isinstance(top_layer.ctx, HttpLayer):
- return HttpLayer(top_layer, "transparent")
+ elif isinstance(top_layer, TlsLayer) and top_layer.client_conn.get_alpn_proto_negotiated() == 'h2':
+ return Http2Layer(top_layer, 'transparent')
+ elif isinstance(top_layer, TlsLayer) and isinstance(top_layer.ctx, Http1Layer):
+ return Http1Layer(top_layer, "transparent")
else:
return RawTcpLayer(top_layer)