Skip to content

Commit

Permalink
Setting app=... or transport=... should bypass environment proxie…
Browse files Browse the repository at this point in the history
…s. (#1122)

* Setting app= or transport= should bypass proxies

* Tweak
  • Loading branch information
tomchristie authored Aug 2, 2020
1 parent e5f8743 commit 0e7730b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions httpx/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ def trust_env(self) -> bool:
return self._trust_env

def _get_proxy_map(
self, proxies: typing.Optional[ProxiesTypes], trust_env: bool,
self, proxies: typing.Optional[ProxiesTypes], allow_env_proxies: bool,
) -> typing.Dict[str, typing.Optional[Proxy]]:
if proxies is None:
if trust_env:
if allow_env_proxies:
return {
key: None if url is None else Proxy(url=url)
for key, url in get_environment_proxies().items()
Expand Down Expand Up @@ -473,7 +473,8 @@ def __init__(
)
limits = pool_limits

proxy_map = self._get_proxy_map(proxies, trust_env)
allow_env_proxies = trust_env and app is None and transport is None
proxy_map = self._get_proxy_map(proxies, allow_env_proxies)

self._transport = self._init_transport(
verify=verify,
Expand Down Expand Up @@ -1003,7 +1004,8 @@ def __init__(
)
limits = pool_limits

proxy_map = self._get_proxy_map(proxies, trust_env)
allow_env_proxies = trust_env and app is None and transport is None
proxy_map = self._get_proxy_map(proxies, allow_env_proxies)

self._transport = self._init_transport(
verify=verify,
Expand Down

0 comments on commit 0e7730b

Please sign in to comment.