Skip to content
Myr

Don't use redirect_cache if allow_redirects=False

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

Fix for #2997

authored by Kenneth Reitz · committed by Kenneth Reitz · parent bbadf47 · Browse files · 1 file+10 added−8 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+10 added−8 removed

  • other:+10 added−8 removed

1 file+10 added−8 removed

modified:requests/sessions.py+10 added-8 removed
551 unmodified lines
552 # Guard against that specific failure case.553 if not isinstance(request, PreparedRequest):554 raise ValueError('You can only send PreparedRequests.')555556 checked_urls = set()557 while request.url in self.redirect_cache:558 checked_urls.add(request.url)559 new_url = self.redirect_cache.get(request.url)560 if new_url in checked_urls:561 break562 request.url = new_url563556 # Set up variables needed for resolve_redirects and dispatching of hooks557 allow_redirects = kwargs.pop('allow_redirects', True)558 stream = kwargs.get('stream')559 hooks = request.hooks560561 # Resolve URL in redirect cache, if available.562 if allow_redirects:563 checked_urls = set()564 while request.url in self.redirect_cache:565 checked_urls.add(request.url)566 new_url = self.redirect_cache.get(request.url)567 if new_url in checked_urls:568 break569 request.url = new_url570571 # Get the appropriate adapter to use572 adapter = self.get_adapter(url=request.url)573574 # Start time (approximately) of the request
108 unmodified lines