mirror of
https://github.com/zulip/zulip.git
synced 2026-06-24 21:08:25 +08:00
tornado: Switch trust_env = False out for no_proxy.
Use the `no_proxy` proxy, which explicitly disables proxy usage for particular hosts. This is a slightly cleaner solution than ignoring all of the environment, as removing proxies is specifically what we are attempting to accomplish.
This commit is contained in:
parent
5bea344fde
commit
89cd31e07c
@ -28,8 +28,11 @@ class TornadoAdapter(HTTPAdapter):
|
||||
cert: Union[None, bytes, str, Container[Union[bytes, str]]] = None,
|
||||
proxies: Optional[Mapping[str, str]] = None,
|
||||
) -> Response:
|
||||
if not proxies:
|
||||
proxies = {}
|
||||
merged_proxies = {**proxies, "no_proxy": "localhost,127.0.0.1"}
|
||||
try:
|
||||
resp = super().send(request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies)
|
||||
resp = super().send(request, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=merged_proxies)
|
||||
except ConnectionError:
|
||||
raise ConnectionError(
|
||||
f"Django cannot connect to Tornado server ({request.url}); "
|
||||
@ -41,12 +44,6 @@ class TornadoAdapter(HTTPAdapter):
|
||||
@lru_cache(None)
|
||||
def requests_client() -> requests.Session:
|
||||
c = requests.Session()
|
||||
if settings.TORNADO_SERVER:
|
||||
if any(host in settings.TORNADO_SERVER for host in ['127.0.0.1', 'localhost']):
|
||||
# Disable trusting the environment, so requests don't
|
||||
# go through any env-configured external proxy.
|
||||
c.trust_env = False
|
||||
|
||||
adapter = TornadoAdapter()
|
||||
for scheme in ("https://", "http://"):
|
||||
c.mount(scheme, adapter)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user