Skip to content

Commit c3767c2

Browse files
scopkevin1024
authored andcommitted
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.
1 parent 6fff3ab commit c3767c2

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

vcr/stubs/aiohttp_stubs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ async def record_responses(cassette, vcr_request, response):
177177
to the final destination.
178178
"""
179179

180-
for past_response in response.history:
180+
for i, past_response in enumerate(response.history):
181181
aiohttp_request = past_response.request_info
182182

183-
# No data because it's following a redirect.
184183
past_request = Request(
185184
aiohttp_request.method,
186185
str(aiohttp_request.url),
187-
None,
186+
# Record body of first request, rest are following a redirect.
187+
None if i else vcr_request.body,
188188
_serialize_headers(aiohttp_request.headers),
189189
)
190190
await record_response(cassette, past_request, past_response)

0 commit comments

Comments
 (0)