Skip to content
Myr

Merge pull request #2193 from sigmavirus24/bug/2192

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

Capture and re-raise urllib3 ProtocolError

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 209a871, 9354855 · Browse files · 2 files+11 added−2 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+11 added−2 removed

  • other:+11 added−2 removed

2 files+11 added−2 removed

modified:requests/adapters.py+3 added-2 removed
21 unmodified lines
22from .packages.urllib3.exceptions import ConnectTimeoutError23from .packages.urllib3.exceptions import HTTPError as _HTTPError24from .packages.urllib3.exceptions import MaxRetryError25from .packages.urllib3.exceptions import ProxyError as _ProxyError26from .packages.urllib3.exceptions import ProtocolError27from .packages.urllib3.exceptions import ReadTimeoutError28from .packages.urllib3.exceptions import SSLError as _SSLError29from .cookies import extract_cookies_to_jar30from .exceptions import (ConnectionError, ConnectTimeout, ReadTimeout, SSLError,
371 unmodified lines
402 else:403 # All is well, return the connection to the pool.404 conn._put_conn(low_conn)405405 except socket.error as sockerr:406 raise ConnectionError(sockerr, request=request)406 except (ProtocolError, socket.error) as err:407 raise ConnectionError(err, request=request)408409 except MaxRetryError as e:410 if isinstance(e.reason, ConnectTimeoutError):411 raise ConnectTimeout(e, request=request)
15 unmodified lines
modified:test_requests.py+8 added
284 unmodified lines
285 s.auth = auth286 r = s.get(url)287 assert r.status_code == 200288289 def test_connection_error(self):290 """Connecting to an unknown domain should raise a ConnectionError"""291 with pytest.raises(ConnectionError):292 requests.get("http://fooobarbangbazbing.httpbin.org")293294 with pytest.raises(ConnectionError):295 requests.get("http://httpbin.org:1")296297 def test_basicauth_with_netrc(self):298 auth = ('user', 'pass')299 wrong_auth = ('wronguser', 'wrongpass')300 url = httpbin('basic-auth', 'user', 'pass')
1189 unmodified lines