aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2016-09-26 17:53:10 -0700
committerMaximilian Hils <git@maximilianhils.com>2016-09-26 17:53:10 -0700
commitf94219e7377e6eb775867918f7a1382421a97c54 (patch)
tree3ba0ae88c475b90d5099377a1a386322d6c6afaf
parent8021427ab919e5301d9cc0e5d6ef28f19dee048b (diff)
downloadmitmproxy-f94219e7377e6eb775867918f7a1382421a97c54.tar.gz
mitmproxy-f94219e7377e6eb775867918f7a1382421a97c54.tar.bz2
mitmproxy-f94219e7377e6eb775867918f7a1382421a97c54.zip
minor fixes
-rw-r--r--mitmproxy/protocol/http.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/mitmproxy/protocol/http.py b/mitmproxy/protocol/http.py
index 894ae465..0a5e040c 100644
--- a/mitmproxy/protocol/http.py
+++ b/mitmproxy/protocol/http.py
@@ -348,12 +348,9 @@ class HttpLayer(base.Layer):
elif self.mode == "upstream":
pass
else:
- # Setting request.host also updates the host header, which we want to preserve
- host_header = flow.request.headers.get("host", None)
- flow.request.host = self.__initial_server_conn.address.host
- flow.request.port = self.__initial_server_conn.address.port
- if host_header:
- flow.request.headers["host"] = host_header
+ # Don't set .host directly, that would update the host header.
+ flow.request.data.host = self.__initial_server_conn.address.host
+ flow.request.data.port = self.__initial_server_conn.address.port
flow.request.scheme = "https" if self.__initial_server_tls else "http"
request_reply = self.channel.ask("request", flow)
@@ -380,10 +377,10 @@ class HttpLayer(base.Layer):
raise exceptions.HttpProtocolException("Cannot change scheme in upstream proxy mode.")
"""
# This is a very ugly (untested) workaround to solve a very ugly problem.
- if self.server_conn and self.server_conn.tls_established and not ssl:
+ if self.server_conn and self.server_conn.tls_established and not tls:
self.disconnect()
self.connect()
- elif ssl and not hasattr(self, "connected_to") or self.connected_to != address:
+ elif tls and not hasattr(self, "connected_to") or self.connected_to != address:
if self.server_conn.tls_established:
self.disconnect()
self.connect()