diff --git a/requests/sessions.py b/requests/sessions.py index 023edfbd31..f987306497 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -535,8 +535,13 @@ def send(self, request, **kwargs): if not isinstance(request, PreparedRequest): raise ValueError('You can only send PreparedRequests.') + checked_urls = set() while request.url in self.redirect_cache: - request.url = self.redirect_cache.get(request.url) + checked_urls.add(request.url) + new_url = self.redirect_cache.get(request.url) + if new_url in checked_urls: + break + request.url = new_url # Set up variables needed for resolve_redirects and dispatching of hooks allow_redirects = kwargs.pop('allow_redirects', True)