Skip to content
Myr

Catch possible exceptions while consuming content of redirect responses.

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

authored by schlamar · committed by schlamar · parent 5893cfc · Browse files · 1 file+6 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

1 file+6 added−2 removed

  • other:+6 added−2 removed

1 file+6 added−2 removed

modified:requests/sessions.py+6 added-2 removed
17 unmodified lines
18 cookiejar_from_dict, extract_cookies_to_jar, RequestsCookieJar, merge_cookies)19from .models import Request, PreparedRequest, DEFAULT_REDIRECT_LIMIT20from .hooks import default_hooks, dispatch_hook21from .utils import to_key_val_list, default_headers, to_native_string22from .exceptions import TooManyRedirects, InvalidSchema22from .exceptions import (23 TooManyRedirects, InvalidSchema, ChunkedEncodingError, ContentDecodingError)24from .structures import CaseInsensitiveDict2526from .adapters import HTTPAdapter27
66 unmodified lines
9495 while resp.is_redirect:96 prepared_request = req.copy()9798 try:97 resp.content # Consume socket so it can be released99 resp.content # Consume socket so it can be released100 except (ChunkedEncodingError, ContentDecodingError, RuntimeError):101 resp.raw.read(decode_content=False)102103 if i >= self.max_redirects:104 raise TooManyRedirects('Exceeded %s redirects.' % self.max_redirects)105
529 unmodified lines