aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-10-03 14:48:42 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-10-03 14:48:51 +0200
commit26631621eef3825b8741eaa7dcc0044bcb7451dd (patch)
treef7947f038f3a05b7ca7a84226b24dde9080a1aaa
parentc6811bd0e854a91bc0c3f9cda676818bd5c76a5c (diff)
downloadmitmproxy-26631621eef3825b8741eaa7dcc0044bcb7451dd.tar.gz
mitmproxy-26631621eef3825b8741eaa7dcc0044bcb7451dd.tar.bz2
mitmproxy-26631621eef3825b8741eaa7dcc0044bcb7451dd.zip
fix #786
-rw-r--r--libmproxy/protocol/http.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py
index 50765e50..8e56c699 100644
--- a/libmproxy/protocol/http.py
+++ b/libmproxy/protocol/http.py
@@ -382,6 +382,7 @@ class HttpLayer(Layer):
def get_request_from_client(self):
request = self.read_request()
if request.headers.get("expect", "").lower() == "100-continue":
+ # TODO: We may have to use send_response_headers for HTTP2 here.
self.send_response(expect_continue_response)
request.headers.pop("expect")
request.body = b"".join(self.read_request_body(request))
@@ -491,8 +492,12 @@ class HttpLayer(Layer):
if flow.request.form_in == "authority":
flow.request.scheme = "http" # pseudo value
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.__original_server_conn.address.host
flow.request.port = self.__original_server_conn.address.port
+ if host_header:
+ flow.request.headers["host"] = host_header
# TODO: This does not really work if we change the first request and --no-upstream-cert is enabled
flow.request.scheme = "https" if self.__original_server_conn.tls_established else "http"