From c3767c2fdbef03cca9768aa37a74fd8969fe6095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 15 Apr 2021 20:49:39 +0300 Subject: [PATCH] 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. --- vcr/stubs/aiohttp_stubs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcr/stubs/aiohttp_stubs.py b/vcr/stubs/aiohttp_stubs.py index d7d7cb8..f71b139 100644 --- a/vcr/stubs/aiohttp_stubs.py +++ b/vcr/stubs/aiohttp_stubs.py @@ -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)