diff options
author | Maximilian Hils <git@maximilianhils.com> | 2020-04-04 16:26:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-04 16:26:48 +0200 |
commit | 0b393b2878ad050d15f06e450ba4e5c94da91b50 (patch) | |
tree | 316928675d004c48b8de1f32d54f5c215c9aee92 | |
parent | ac83db3b840ecdbbc8ba232ae151b75d15e4a679 (diff) | |
parent | 5e0a89dbc8752f4e90cd8caa9702372a6546631b (diff) | |
download | mitmproxy-0b393b2878ad050d15f06e450ba4e5c94da91b50.tar.gz mitmproxy-0b393b2878ad050d15f06e450ba4e5c94da91b50.tar.bz2 mitmproxy-0b393b2878ad050d15f06e450ba4e5c94da91b50.zip |
Merge pull request #3899 from mhils/dont-add-host-header
Don't force host header on outgoing requests
-rw-r--r-- | mitmproxy/net/http/http1/assemble.py | 11 | ||||
-rw-r--r-- | test/mitmproxy/net/http/http1/test_assemble.py | 12 |
2 files changed, 1 insertions, 22 deletions
diff --git a/mitmproxy/net/http/http1/assemble.py b/mitmproxy/net/http/http1/assemble.py index 8b7246f7..d30a74a1 100644 --- a/mitmproxy/net/http/http1/assemble.py +++ b/mitmproxy/net/http/http1/assemble.py @@ -1,4 +1,3 @@ -import mitmproxy.net.http.url from mitmproxy import exceptions @@ -78,15 +77,7 @@ def _assemble_request_headers(request_data): Args: request_data (mitmproxy.net.http.request.RequestData) """ - headers = request_data.headers - if "host" not in headers and request_data.scheme and request_data.host and request_data.port: - headers = headers.copy() - headers["host"] = mitmproxy.net.http.url.hostport( - request_data.scheme, - request_data.host, - request_data.port - ) - return bytes(headers) + return bytes(request_data.headers) def _assemble_response_line(response_data): diff --git a/test/mitmproxy/net/http/http1/test_assemble.py b/test/mitmproxy/net/http/http1/test_assemble.py index ab177885..4b4ab414 100644 --- a/test/mitmproxy/net/http/http1/test_assemble.py +++ b/test/mitmproxy/net/http/http1/test_assemble.py @@ -15,7 +15,6 @@ def test_assemble_request(): b"GET /path HTTP/1.1\r\n" b"header: qvalue\r\n" b"content-length: 7\r\n" - b"host: address:22\r\n" b"\r\n" b"content" ) @@ -84,17 +83,6 @@ def test_assemble_request_headers(): assert b"Transfer-Encoding" in c -def test_assemble_request_headers_host_header(): - r = treq() - r.headers = Headers() - c = _assemble_request_headers(r.data) - assert b"host" in c - - r.host = None - c = _assemble_request_headers(r.data) - assert b"host" not in c - - def test_assemble_response_headers(): # https://github.com/mitmproxy/mitmproxy/issues/186 r = tresp(content=b"") |