diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-06-23 09:40:25 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-06-23 09:40:25 +1200 |
commit | e2069d52a81a2aef99dcd2da4fbc61e926b024a0 (patch) | |
tree | 92986b2fda60ae8a24932d892da8469932d654a8 /libmproxy/protocol/http.py | |
parent | 159543dd2b2f0f38ba4f86109d58b7a2e53d6566 (diff) | |
parent | fbb23b5c9fae6e402d84ddae3c3b8c218def366c (diff) | |
download | mitmproxy-e2069d52a81a2aef99dcd2da4fbc61e926b024a0.tar.gz mitmproxy-e2069d52a81a2aef99dcd2da4fbc61e926b024a0.tar.bz2 mitmproxy-e2069d52a81a2aef99dcd2da4fbc61e926b024a0.zip |
Merge pull request #638 from iroiro123/http-transparent
HTTP Transparent Proxy
Diffstat (limited to 'libmproxy/protocol/http.py')
-rw-r--r-- | libmproxy/protocol/http.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 9c143386..9bce7206 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -1328,8 +1328,34 @@ class HTTPHandler(ProtocolHandler): # value at flow.server_conn self.c.set_server_address((request.host, request.port)) flow.server_conn = self.c.server_conn - + + elif request.form_in == "relative": + if self.c.config.mode == "spoof": + # Host header + h = request.pretty_host(hostheader=True) + if h is None: + raise http.HttpError( + 400, + "Invalid request: No host information" + ) + p = http.parse_url("http://" + h) + request.scheme = p[0] + request.host = p[1] + request.port = p[2] + self.c.set_server_address((request.host, request.port)) + flow.server_conn = self.c.server_conn + + if self.c.config.mode == "sslspoof": + # SNI is processed in server.py + if not (flow.server_conn and flow.server_conn.ssl_established): + print ":::::::::::::::" + raise http.HttpError( + 400, + "Invalid request: No host information" + ) + return None + raise http.HttpError( 400, "Invalid HTTP request form (expected: %s, got: %s)" % ( self.expected_form_in, request.form_in |