mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
commit
5c734b3cd6
@ -8,6 +8,7 @@ from mitmproxy import connections # noqa
|
|||||||
from mitmproxy import exceptions
|
from mitmproxy import exceptions
|
||||||
from mitmproxy import http
|
from mitmproxy import http
|
||||||
from mitmproxy import flow
|
from mitmproxy import flow
|
||||||
|
from mitmproxy.net.http import url
|
||||||
from mitmproxy.proxy.protocol import base
|
from mitmproxy.proxy.protocol import base
|
||||||
from mitmproxy.proxy.protocol.websocket import WebSocketLayer
|
from mitmproxy.proxy.protocol.websocket import WebSocketLayer
|
||||||
from mitmproxy.net import websocket
|
from mitmproxy.net import websocket
|
||||||
@ -326,7 +327,10 @@ class HttpLayer(base.Layer):
|
|||||||
|
|
||||||
# update host header in reverse proxy mode
|
# update host header in reverse proxy mode
|
||||||
if self.config.options.mode.startswith("reverse:") and not self.config.options.keep_host_header:
|
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
|
# Determine .scheme, .host and .port attributes for inline scripts. For
|
||||||
# absolute-form requests, they are directly given in the request. For
|
# absolute-form requests, they are directly given in the request. For
|
||||||
|
@ -452,7 +452,7 @@ class TestReverse(tservers.ReverseProxyTest, CommonMixin, TcpMixin):
|
|||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
|
|
||||||
req = self.master.state.flows[0].request
|
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
|
@pytest.mark.asyncio
|
||||||
async def test_selfconnection(self):
|
async def test_selfconnection(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user