mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 09:13:23 +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:
committed by
Kevin McCarthy
parent
6fff3ab952
commit
c3767c2fdb
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user