diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-09-26 18:07:04 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-09-26 18:07:04 -0700 |
commit | ebccc103d83959123d39efe6803a9c24b7da0951 (patch) | |
tree | 384e9570552fe1db8a72cf0c6a263746a300f28b | |
parent | f94219e7377e6eb775867918f7a1382421a97c54 (diff) | |
download | mitmproxy-ebccc103d83959123d39efe6803a9c24b7da0951.tar.gz mitmproxy-ebccc103d83959123d39efe6803a9c24b7da0951.tar.bz2 mitmproxy-ebccc103d83959123d39efe6803a9c24b7da0951.zip |
Revert "minor fixes"
This reverts commit f94219e7377e6eb775867918f7a1382421a97c54.
-rw-r--r-- | mitmproxy/protocol/http.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/mitmproxy/protocol/http.py b/mitmproxy/protocol/http.py index 0a5e040c..894ae465 100644 --- a/mitmproxy/protocol/http.py +++ b/mitmproxy/protocol/http.py @@ -348,9 +348,12 @@ class HttpLayer(base.Layer): elif self.mode == "upstream": pass else: - # 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 + # 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 flow.request.scheme = "https" if self.__initial_server_tls else "http" request_reply = self.channel.ask("request", flow) @@ -377,10 +380,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 tls: + if self.server_conn and self.server_conn.tls_established and not ssl: self.disconnect() self.connect() - elif tls and not hasattr(self, "connected_to") or self.connected_to != address: + elif ssl and not hasattr(self, "connected_to") or self.connected_to != address: if self.server_conn.tls_established: self.disconnect() self.connect() |