From 01303f4de043c74952462e9157db5d60bb6f9961 Mon Sep 17 00:00:00 2001 From: kls602 Date: Sun, 15 Dec 2019 12:18:04 -0500 Subject: [PATCH] Added no proxy check for issue #4431 --- .gitignore | 1 + aiohttp/client.py | 13 ++++++++----- aiohttp/helpers.py | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) 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