aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/protocol
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-09-11 00:00:00 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-09-11 00:00:00 +0200
commitd1bc966e5b7e2ef822443f3ad28a5f3d40965e75 (patch)
tree3468125e5579adce3295b4055012c329ebc6d27a /libmproxy/protocol
parent33c0d3653077c9e6834034ec03a42beeba3ca7d7 (diff)
downloadmitmproxy-d1bc966e5b7e2ef822443f3ad28a5f3d40965e75.tar.gz
mitmproxy-d1bc966e5b7e2ef822443f3ad28a5f3d40965e75.tar.bz2
mitmproxy-d1bc966e5b7e2ef822443f3ad28a5f3d40965e75.zip
polish for release: introduce http2 and rawtcp as command line switches
Diffstat (limited to 'libmproxy/protocol')
-rw-r--r--libmproxy/protocol/http.py10
-rw-r--r--libmproxy/protocol/tls.py8
2 files changed, 14 insertions, 4 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index 52164241..308fa0a0 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -16,7 +16,7 @@ from ..models import (
HTTPFlow, HTTPRequest, HTTPResponse, make_error_response, make_connect_response, Error
)
from .base import Layer, Kill
-
+from .rawtcp import RawTCPLayer
class _HttpLayer(Layer):
supports_streaming = False
@@ -364,7 +364,13 @@ class HttpLayer(Layer):
if self.check_close_connection(flow):
return
- # TODO: Implement HTTP Upgrade
+ # Handle 101 Switching Protocols
+ # It may be useful to pass additional args (such as the upgrade header)
+ # to next_layer in the future
+ if flow.response.status_code == 101:
+ layer = self.ctx.next_layer(self)
+ layer()
+ return
# Upstream Proxy Mode: Handle CONNECT
if flow.request.form_in == "authority" and flow.response.code == 200:
diff --git a/libmproxy/protocol/tls.py b/libmproxy/protocol/tls.py
index 6e8535ae..2cddb1dd 100644
--- a/libmproxy/protocol/tls.py
+++ b/libmproxy/protocol/tls.py
@@ -3,6 +3,8 @@ from __future__ import (absolute_import, print_function, division)
import struct
from construct import ConstructError
+import six
+import sys
from netlib.tcp import NetLibError, NetLibInvalidCertificateError
from netlib.http.http1 import HTTP1Protocol
@@ -387,7 +389,7 @@ class TlsLayer(Layer):
self._establish_tls_with_client()
except:
pass
- raise e
+ six.reraise(*sys.exc_info())
self._establish_tls_with_client()
@@ -416,9 +418,11 @@ class TlsLayer(Layer):
# and mitmproxy would enter TCP passthrough mode, which we want to avoid.
deprecated_http2_variant = lambda x: x.startswith("h2-") or x.startswith("spdy")
if self.client_alpn_protocols:
- alpn = filter(lambda x: not deprecated_http2_variant(x), self.client_alpn_protocols)
+ alpn = [x for x in self.client_alpn_protocols if not deprecated_http2_variant(x)]
else:
alpn = None
+ if alpn and "h2" in alpn and not self.config.http2 :
+ alpn.remove("h2")
ciphers_server = self.config.ciphers_server
if not ciphers_server: