diff --git a/.gitignore b/.gitignore index 03b8b6b0e36..009d9ba2b54 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,4 @@ virtualenv.py pip-wheel-metadata .test-results coverage.xml +.venv/ diff --git a/aiohttp/client.py b/aiohttp/client.py index 61268292d65..e1d11c11a20 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -84,6 +84,7 @@ ceil_timeout, get_running_loop, proxies_from_env, + proxy_bypass, sentinel, strip_auth_from_url, ) @@ -422,11 +423,13 @@ async def _request( if proxy is not None: proxy = URL(proxy) elif self._trust_env: - for scheme, proxy_info in proxies_from_env().items(): - if scheme == url.scheme: - proxy = proxy_info.proxy - proxy_auth = proxy_info.proxy_auth - break + if not proxy_bypass(str(url.host)): + for scheme, proxy_info in proxies_from_env()\ + .items(): + if scheme == url.scheme: + proxy = proxy_info.proxy + proxy_auth = proxy_info.proxy_auth + break req = self._request_class( method, url, params=params, headers=headers, diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py index 00ec9a5015d..7c94084477e 100644 --- a/aiohttp/helpers.py +++ b/aiohttp/helpers.py @@ -39,7 +39,7 @@ cast, ) from urllib.parse import quote -from urllib.request import getproxies +from urllib.request import getproxies, proxy_bypass # noqa: F401 import async_timeout import attr