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

Keep the same request method when following redirects for non 303 responses in httpx #552

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kestutisbalt
Copy link

@kestutisbalt kestutisbalt commented Aug 18, 2020

Request method should be kept the same whenever redirect is not 302 and 303

@codecov-commenter
Copy link

codecov-commenter commented Aug 18, 2020

Codecov Report

Merging #552 into master will decrease coverage by 5.42%.
The diff coverage is 65.52%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #552      +/-   ##
==========================================
- Coverage   89.41%   83.98%   -5.43%     
==========================================
  Files          24       26       +2     
  Lines        1549     1705     +156     
  Branches      216      239      +23     
==========================================
+ Hits         1385     1432      +47     
- Misses        135      238     +103     
- Partials       29       35       +6     
Impacted Files Coverage Δ
vcr/stubs/boto3_stubs.py 56.25% <0.00%> (+0.69%) ⬆️
vcr/stubs/httpx_stubs.py 0.00% <0.00%> (ø)
vcr/stubs/tornado_stubs.py 0.00% <0.00%> (ø)
vcr/patch.py 82.74% <61.11%> (-1.56%) ⬇️
vcr/filters.py 93.61% <66.66%> (ø)
vcr/stubs/aiohttp_stubs.py 94.30% <94.30%> (ø)
vcr/cassette.py 96.20% <100.00%> (-0.97%) ⬇️
vcr/config.py 95.00% <100.00%> (-0.07%) ⬇️
vcr/errors.py 100.00% <100.00%> (ø)
vcr/matchers.py 96.05% <100.00%> (+0.05%) ⬆️
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d0fdba...c2a5f20. Read the comment docs.

@kestutisbalt kestutisbalt changed the title Handle 307 and 308 redirect method in httpx Keep the same request method when following redirects for non 303 responses in httpx Aug 18, 2020
@@ -108,7 +108,8 @@ def _play_responses(cassette, request, vcr_request, client, kwargs):
if not next_url:
break

vcr_request = VcrRequest("GET", next_url, None, dict(response.headers))
method = request.method if response.status_code != 303 else "GET"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its tricky to know what would be the best logic here because it is not strictly mandated by the HTTP spec.

However according to https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections the only status code that always changes to GET method is 303. So this LGTM!

@@ -108,7 +108,11 @@ def _play_responses(cassette, request, vcr_request, client, kwargs):
if not next_url:
break

vcr_request = VcrRequest("GET", next_url, None, dict(response.headers))
# Even though 302 shouldn't change request's method, browsers like Chromium
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does what browsers do here matter?

@kevin1024 kevin1024 force-pushed the master branch 3 times, most recently from df3997c to 34d5384 Compare June 26, 2023 17:54
@parkerhancock
Copy link
Contributor

I suggest we close this one in view of #784

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.

5 participants