Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1955: Do not use original request in redirect #1963

Merged
merged 1 commit into from
Mar 24, 2014

Conversation

sigmavirus24
Copy link
Contributor

The original request was never being properly overriden in resolve_redirects.
As such being having a POST request respond with a 303 would generate a GET
request. If the GET request encountered another redirect to something like a
307, then it would use the original request and generate another POST request.

There are two parts to this fix:

  • The fix itself
  • The test infrastructure to ensure it does not regress because HTTPBin is
    insufficient

The original request was never being properly overriden in resolve_redirects.
As such being having a POST request respond with a 303 would generate a GET
request. If the GET request encountered another redirect to something like a
307, then it would use the original request and generate another POST request.

There are two parts to this fix:

- The fix itself
- The test infrastructure to ensure it does not regress because HTTPBin is
  insufficient
@zackw
Copy link
Contributor

zackw commented Mar 15, 2014

The code change seems correct to me.

Re the test infrastructure, though, may I suggest you write a mock adapter object rather than a mock session object? That may be a bit more work, but it would be a more "natural" test (in the sense that more of the normal logic is exercised), and it would be more easily generalizable to cases like the bad gzipped response body in #1944.

@sigmavirus24
Copy link
Contributor Author

We could use Betamax but we don't have a real URL to test this against.

@zackw
Copy link
Contributor

zackw commented Mar 15, 2014

I was imagining an adapter that wasn't backed by any actual network activity, just an internal list of pseudo-URLs and how it should react to them.

@sigmavirus24
Copy link
Contributor Author

Betamax only needs the network once. After the responses are recorded, it would respond to an internal list of URLs and it would know how to react to them.

@Lukasa
Copy link
Member

Lukasa commented Mar 16, 2014

LGTM.

I'll let you come up with a testing plan.

@sigmavirus24
Copy link
Contributor Author

@kennethreitz since you're around, care to weigh in on this one?

@kennethreitz
Copy link
Contributor

Wow, this is an old, old, old bug. I totally forgot about it.

kennethreitz added a commit that referenced this pull request Mar 24, 2014
Fix #1955: Do not use original request in redirect
@kennethreitz kennethreitz merged commit 5f48e4a into psf:master Mar 24, 2014
@sigmavirus24 sigmavirus24 deleted the fix-redirect-methods branch March 24, 2014 16:25
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants