diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-10-03 14:48:42 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-10-03 14:48:51 +0200 |
commit | 26631621eef3825b8741eaa7dcc0044bcb7451dd (patch) | |
tree | f7947f038f3a05b7ca7a84226b24dde9080a1aaa /libmproxy | |
parent | c6811bd0e854a91bc0c3f9cda676818bd5c76a5c (diff) | |
download | mitmproxy-26631621eef3825b8741eaa7dcc0044bcb7451dd.tar.gz mitmproxy-26631621eef3825b8741eaa7dcc0044bcb7451dd.tar.bz2 mitmproxy-26631621eef3825b8741eaa7dcc0044bcb7451dd.zip |
fix #786
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/protocol/http.py | 5 |
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" |