class InvalidMethod(RequestException):
"""An inappropriate method was attempted."""
+
+class TooManyRedirects(RequestException):
+ """Too many redirects."""
from .structures import CaseInsensitiveDict
from .packages.poster.encode import multipart_encode
from .packages.poster.streaminghttp import register_openers, get_handlers
-from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod
+from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod, TooManyRedirects
REDIRECT_STATI = (301, 302, 303, 307)
(self.allow_redirects))
):
+ if not len(history) < 30:
+ raise TooManyRedirects()
+
history.append(r)
url = r.headers['location']