mirror of https://github.com/scrapy/scrapy.git
check for unparseable no_proxy values
This commit is contained in:
parent
c1cc3f2f42
commit
959222df7e
|
|
@ -13,7 +13,12 @@ class HttpProxyMiddleware:
|
|||
self.auth_encoding = auth_encoding
|
||||
self.proxies = {}
|
||||
for type_, url in getproxies().items():
|
||||
self.proxies[type_] = self._get_proxy(url, type_)
|
||||
try:
|
||||
self.proxies[type_] = self._get_proxy(url, type_)
|
||||
# some values such as '/var/run/docker.sock' can't be parsed
|
||||
# by _parse_proxy and as such should be skipped
|
||||
except ValueError:
|
||||
continue
|
||||
|
||||
@classmethod
|
||||
def from_crawler(cls, crawler):
|
||||
|
|
|
|||
|
|
@ -123,7 +123,11 @@ class TestHttpProxyMiddleware(TestCase):
|
|||
|
||||
def test_no_proxy(self):
|
||||
os.environ['http_proxy'] = 'https://proxy.for.http:3128'
|
||||
os.environ['no_proxy'] = '/var/run/docker.sock'
|
||||
mw = HttpProxyMiddleware()
|
||||
# '/var/run/docker.sock' may be used by the user for
|
||||
# no_proxy value but is not parseable and should be skipped
|
||||
assert 'no' not in mw.proxies
|
||||
|
||||
os.environ['no_proxy'] = '*'
|
||||
req = Request('http://noproxy.com')
|
||||
|
|
|
|||
Loading…
Reference in New Issue