Skip to content

Commit e7d3348

Browse files
authored
Fixing VCR redirection (Azure#20747)
Using the location passed as part of the redirection response if it is an absolute URL.
1 parent 856f247 commit e7d3348

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/vcrpy/vcr/stubs/aiohttp_stubs/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ def play_responses(cassette, vcr_request):
9595
# If we're following redirects, continue playing until we reach
9696
# our final destination.
9797
while 300 <= response.status <= 399:
98-
next_url = URL(response.url).with_path(response.headers["location"])
98+
new_location = response.headers["location"]
99+
potential_next_url = URL(new_location)
100+
next_url = (potential_next_url
101+
if potential_next_url.is_absolute()
102+
else URL(response.url).with_path(new_location))
99103

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

0 commit comments

Comments
 (0)