1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 01:03:24 +00:00

fix(aiohttp): record body of first request in redirect chain

The first could be e.g. a POST with one, only the remaining ones are
expected to be GETs without one.
This commit is contained in:
Ville Skyttä
2021-04-15 20:49:39 +03:00
committed by Kevin McCarthy
parent 6fff3ab952
commit c3767c2fdb

View File

@@ -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)