Skip to content

fix: preserve request method changes across redirect chains in Session.resolve_redirects#97

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

fix: preserve request method changes across redirect chains in Session.resolve_redirects#97
label-hook[bot] wants to merge 1217 commits into
mainfrom
phoenix/issue-96

Conversation

@label-hook

@label-hook label-hook Bot commented Apr 18, 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 made by intermediate redirects (e.g., POST → GET conversion on 303 See Other).

Changes

  • Modified Session.resolve_redirects method in requests/sessions.py to track and use the current request state instead of always copying from the original request
  • Ensured that HTTP method changes (like POST to GET on 303 redirects) are preserved for subsequent redirects in the chain
  • Maintained backward compatibility for single redirect scenarios

Testing

The fix addresses the specific scenario described in the issue:

  1. POST request receives 303 See Other redirect (converts to GET)
  2. GET request receives 307 Temporary Redirect (should preserve GET method)
  3. Previously: Final request incorrectly used POST method
  4. Now: Final request correctly uses GET method

Baseline test suite results show no new test failures introduced by this change.

Closes #96


Closes #96

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 18, 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