58 lines
2.6 KiB
Diff
58 lines
2.6 KiB
Diff
# psf__requests-2674
|
|
# Loki Mode Multi-Agent Patch
|
|
# Attempts: 1
|
|
|
|
--- a/requests/adapters.py
|
|
+++ b/requests/adapters.py
|
|
@@ -17,6 +17,8 @@ from .packages.urllib3.poolmanager import PoolManager, proxy_from_url
|
|
from .packages.urllib3.response import HTTPResponse
|
|
from .packages.urllib3.util import Timeout as TimeoutSauce
|
|
from .packages.urllib3.util.retry import Retry
|
|
+from .packages.urllib3.exceptions import ClosedPoolError
|
|
+from .packages.urllib3.exceptions import LocationParseError
|
|
from .compat import urlparse, basestring
|
|
from .utils import (DEFAULT_CA_BUNDLE_PATH, get_encoding_from_headers,
|
|
prepend_scheme_if_needed, get_auth_from_url, urldefragauth)
|
|
@@ -24,6 +26,7 @@ from .structures import CaseInsensitiveDict
|
|
from .packages.urllib3.exceptions import MaxRetryError
|
|
from .packages.urllib3.exceptions import TimeoutError
|
|
from .packages.urllib3.exceptions import SSLError as _SSLError
|
|
+from .packages.urllib3.exceptions import HTTPError as _HTTPError
|
|
from .packages.urllib3.exceptions import ProxyError as _ProxyError
|
|
from .cookies import extract_cookies_to_jar
|
|
from .exceptions import (ConnectionError, ConnectTimeout, ReadTimeout, SSLError,
|
|
@@ -330,6 +333,12 @@ class HTTPAdapter(BaseAdapter):
|
|
|
|
except (_SSLError, _HTTPError) as e:
|
|
if isinstance(e, _SSLError):
|
|
raise SSLError(e, request=request)
|
|
+ elif isinstance(e, ClosedPoolError):
|
|
+ raise ConnectionError(e, request=request)
|
|
+ elif isinstance(e, TimeoutError):
|
|
+ raise Timeout(e, request=request)
|
|
+ elif isinstance(e, LocationParseError):
|
|
+ raise InvalidURL(e, request=request)
|
|
elif isinstance(e, ReadTimeoutError):
|
|
raise ReadTimeout(e, request=request)
|
|
else:
|
|
--- a/requests/models.py
|
|
+++ b/requests/models.py
|
|
@@ -21,6 +21,7 @@ from .packages.urllib3.fields import RequestField
|
|
from .packages.urllib3.filepost import encode_multipart_formdata
|
|
from .packages.urllib3.util import parse_url
|
|
from .packages.urllib3.exceptions import (
|
|
+ DecodeError,
|
|
ReadTimeoutError,
|
|
ProtocolError)
|
|
from .exceptions import (
|
|
@@ -572,8 +573,11 @@ class Response(object):
|
|
raise ChunkedEncodingError(e)
|
|
except DecodeError as e:
|
|
raise ContentDecodingError(e)
|
|
+ except ReadTimeoutError as e:
|
|
+ raise ConnectionError(e)
|
|
except AttributeError:
|
|
# Standard file-like object.
|
|
while True:
|
|
chunk = self.raw.read(chunk_size)
|
|
if not chunk:
|