Skip to content

Fix: Include initial response in resolve_redirects iterable (#1953)Fix redirect iterable#7203

Closed
Satvi27-debug wants to merge 4 commits intopsf:mainfrom
Satvi27-debug:fix-redirect-iterable
Closed

Fix: Include initial response in resolve_redirects iterable (#1953)Fix redirect iterable#7203
Satvi27-debug wants to merge 4 commits intopsf:mainfrom
Satvi27-debug:fix-redirect-iterable

Conversation

@Satvi27-debug
Copy link

This Pull Request addresses feature request #1953 by modifying the resolve_redirects generator in sessions.py.

Currently, the iterable produced by Session.resolve_redirects excludes the very first response that triggered the redirect chain. I have added a yield resp statement before the history tracking loop begins.

This change allows developers to process the entire redirect sequence—including the origin response—within a single for loop, eliminating the need for duplicate logic. The implementation includes a check for yield_requests to ensure backward compatibility and correct behavior when walking requests instead of responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants