Skip to content

fix: preserve request method changes in redirect chains#70

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

fix: preserve request method changes in redirect chains#70
label-hook[bot] wants to merge 1217 commits into
mainfrom
phoenix/issue-69

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 in a chain, instead of preserving method changes from intermediate redirects like 303 See Other.

Changes

  • Modified Session.resolve_redirects in requests/sessions.py to use the most recent request state instead of always copying the original request
  • Updated the request preparation logic to preserve method changes from previous redirects (e.g., POST → GET conversion from 303 See Other)
  • Ensured that redirect chains now correctly maintain the appropriate HTTP method for each subsequent redirect

Testing

The fix was validated to ensure:

  • Redirect chains with 303 See Other followed by 307 Temporary Redirect now correctly preserve the GET method from the 303
  • Normal redirect behavior remains unchanged
  • Various combinations of redirect status codes continue to work according to HTTP specifications
  • No new test failures were introduced (baseline test suite status maintained)

Closes #69


Closes #69

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