Skip to content

fix: preserve method changes in redirect chains by using current request#79

Open
label-hook[bot] wants to merge 1217 commits into
mainfrom
phoenix/issue-78
Open

fix: preserve method changes in redirect chains by using current request#79
label-hook[bot] wants to merge 1217 commits into
mainfrom
phoenix/issue-78

Conversation

@label-hook

@label-hook label-hook Bot commented Apr 13, 2026

Copy link
Copy Markdown

Summary

Fixes an issue where Session.resolve_redirects incorrectly reverted to the original request method for subsequent redirects after a method-changing redirect (like 303 See Other). The method was copying the original request for each redirect iteration instead of using the current/modified request state.

Changes

  • Modified Session.resolve_redirects in requests/sessions.py to copy from the current prepared request instead of the original request for subsequent redirects
  • This ensures that method changes from redirects like 303 (POST → GET) are preserved in subsequent redirects like 307
  • The fix maintains the current request state throughout the redirect chain instead of reverting to the original request

Testing

The implementation was tested against the baseline test suite. While the baseline suite had pre-existing failures unrelated to this change, no new test failures were introduced by this fix. The change specifically addresses the redirect chain scenario described in the issue:

  1. POST request receives 303 See Other (converts to GET)
  2. Subsequent 307 redirect should preserve the GET method
  3. Previously would incorrectly revert to original POST method
  4. Now correctly maintains the GET method

Closes #78


Closes #78

Kenneth Reitz and others added 30 commits October 24, 2013 10:28
Add clarification to MissingSchema error
Use builtin_str for all auto-set header values.
otherwise python3.4 warns
Modified the tests so that they use py.test convention
Improve the PreparedRequest docs.
loosen URL handling for non-native protocols
This reverts commit a8300c0, reversing
changes made to 2e196be.
Lukasa and others added 27 commits February 4, 2014 00:53
One last Charade reference to remove here.
Reference at the earliest opportunity that Server-Name-Indication is a
limitation of Python 2.6 and 2.7. Avoid describing it as a Requests
issue.
Made `.status_code` and `.reason` consistent with one another, adding some examples. Addresses psf#1225.
Document the `Response.reason` attribute.
…coding

Reinstate falling back to self.text for JSON responses
Document requirements for SNI support on Python2
New Response property, .is_redirect.
- Regardless of whether they are on the session or not
- Fixes psf#1920
The timeout is in seconds.
- Charade is gone, long live Chardet.
- cacert.pem is now taken wholesale from Mozilla so we need to display that
  itis licensed under the MPL2.0
Charade -> Chardet and Add cacert.pem license
Add timeout to stream with testing
Some people will assume that .raw() is present, and they shouldn't get
AttributeErrors when they make that assumption on a pickled Response.
However, @kennethreitz has asked that we not be too dependent on
urllib3. For that reason, set to None.
Pickled Responses should include a None value for the raw attribute
Fix Accept-Encoding in default headers
@label-hook label-hook Bot added the ai:review Phoenix AI: PR ready for review label Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:review Phoenix AI: PR ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SWE-bench] psf__requests-1963