Skip to content

Commit

Permalink
fix(aiohttp): record body of first request in redirect chain
Browse files Browse the repository at this point in the history
The first could be e.g. a POST with one, only the remaining ones are
expected to be GETs without one.
  • Loading branch information
scop authored and kevin1024 committed Aug 31, 2022
1 parent 6fff3ab commit c3767c2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions vcr/stubs/aiohttp_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,14 @@ async def record_responses(cassette, vcr_request, response):
to the final destination.
"""

for past_response in response.history:
for i, past_response in enumerate(response.history):
aiohttp_request = past_response.request_info

# No data because it's following a redirect.
past_request = Request(
aiohttp_request.method,
str(aiohttp_request.url),
None,
# Record body of first request, rest are following a redirect.
None if i else vcr_request.body,
_serialize_headers(aiohttp_request.headers),
)
await record_response(cassette, past_request, past_response)
Expand Down

0 comments on commit c3767c2

Please sign in to comment.