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

Fixing VCR redirection #20747

Merged
merged 1 commit into from
Sep 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tools/vcrpy/vcr/stubs/aiohttp_stubs/__init__.py
Original file line number Diff line number Diff line change
@@ -95,7 +95,11 @@ def play_responses(cassette, vcr_request):
# If we're following redirects, continue playing until we reach
# our final destination.
while 300 <= response.status <= 399:
next_url = URL(response.url).with_path(response.headers["location"])
new_location = response.headers["location"]
potential_next_url = URL(new_location)
next_url = (potential_next_url
if potential_next_url.is_absolute()
else URL(response.url).with_path(new_location))

# Make a stub VCR request that we can then use to look up the recorded
# VCR request saved to the cassette. This feels a little hacky and