Skip to content
Myr

Merge pull request #3059 from alexanderad/proxy-connection-errors

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Raise a ProxyError for proxy related connection issues

authored by Kenneth Reitz · committed by Kenneth Reitz · parents e576f98, 6ca9d71 · Browse files · 2 files+10 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−1 removed

  • tests:+7 added−1 removed
  • other:+3 added−0 removed

2 files+10 added−1 removed

modified:requests/adapters.py+3 added
432 unmodified lines
433434 if isinstance(e.reason, ResponseError):435 raise RetryError(e, request=request)436437 if isinstance(e.reason, _ProxyError):438 raise ProxyError(e, request=request)439440 raise ConnectionError(e, request=request)441442 except ClosedPoolError as e:443 raise ConnectionError(e, request=request)
13 unmodified lines
modified:tests/test_requests.py+7 added-1 removed
19 unmodified lines
20 builtin_str, OrderedDict)21from requests.cookies import cookiejar_from_dict, morsel_to_cookie22from requests.exceptions import (23 ConnectionError, ConnectTimeout, InvalidSchema, InvalidURL,24 MissingSchema, ReadTimeout, Timeout, RetryError, TooManyRedirects)24 MissingSchema, ReadTimeout, Timeout, RetryError, TooManyRedirects,25 ProxyError)26from requests.models import PreparedRequest27from requests.structures import CaseInsensitiveDict28from requests.sessions import SessionRedirectMixin29from requests.models import urlencode
328 unmodified lines
358 def test_errors(self, url, exception):359 with pytest.raises(exception):360 requests.get(url, timeout=1)361362 def test_proxy_error(self):363 # any proxy related error (address resolution, no route to host, etc) should result in a ProxyError364 with pytest.raises(ProxyError):365 requests.get('http://localhost:1', proxies={'http': 'non-resolvable-address'})366367 def test_basicauth_with_netrc(self, httpbin):368 auth = ('user', 'pass')369 wrong_auth = ('wronguser', 'wrongpass')370 url = httpbin('basic-auth', 'user', 'pass')
1165 unmodified lines