Merge pull request #4333 from mhils/issue-4280

fix #4280
This commit is contained in:
Maximilian Hils 2020-12-10 09:55:29 +01:00 committed by GitHub
commit 5c734b3cd6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -8,6 +8,7 @@ from mitmproxy import connections # noqa
from mitmproxy import exceptions
from mitmproxy import http
from mitmproxy import flow
from mitmproxy.net.http import url
from mitmproxy.proxy.protocol import base
from mitmproxy.proxy.protocol.websocket import WebSocketLayer
from mitmproxy.net import websocket
@ -326,7 +327,10 @@ class HttpLayer(base.Layer):
# update host header in reverse proxy mode
if self.config.options.mode.startswith("reverse:") and not self.config.options.keep_host_header:
f.request.host_header = self.config.upstream_server.address[0]
f.request.host_header = url.hostport(
self.config.upstream_server.scheme,
*self.config.upstream_server.address
)
# Determine .scheme, .host and .port attributes for inline scripts. For
# absolute-form requests, they are directly given in the request. For

View File

@ -452,7 +452,7 @@ class TestReverse(tservers.ReverseProxyTest, CommonMixin, TcpMixin):
assert resp.status_code == 200
req = self.master.state.flows[0].request
assert req.host_header == "127.0.0.1"
assert req.host_header.startswith("127.0.0.1:")
@pytest.mark.asyncio
async def test_selfconnection(self):