Skip to content
Myr

Handle too many redirects.

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

authored by Jérémy Bethmont · committed by Jérémy Bethmont · parent e776242 · Browse files · 2 files+7 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+7 added−1 removed

  • other:+7 added−1 removed

2 files+7 added−1 removed

modified:requests/exceptions.py+3 added
19 unmodified lines
20 """A valid URL is required to make a request."""2122class InvalidMethod(RequestException):23 """An inappropriate method was attempted."""2425class TooManyRedirects(RequestException):26 """Too many redirects."""
modified:requests/models.py+4 added-1 removed
18 unmodified lines
19from .monkeys import Request as _Request, HTTPBasicAuthHandler, HTTPForcedBasicAuthHandler, HTTPDigestAuthHandler, HTTPRedirectHandler20from .structures import CaseInsensitiveDict21from .packages.poster.encode import multipart_encode22from .packages.poster.streaminghttp import register_openers, get_handlers23from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod23from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod, TooManyRedirects242526REDIRECT_STATI = (301, 302, 303, 307)27
163 unmodified lines
191 (r.status_code is 303) or192 (self.allow_redirects))193 ):194195 if not len(history) < 30:196 raise TooManyRedirects()197198 history.append(r)199200 url = r.headers['location']201
376 unmodified lines