From 1b9f80d74143499a7742a9e6d253cfbe74898c6c Mon Sep 17 00:00:00 2001 From: Paulo Romeira Date: Wed, 17 Jun 2020 21:51:59 -0300 Subject: [PATCH] aiohttp: Ignore cookie expiration date --- vcr/stubs/aiohttp_stubs.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vcr/stubs/aiohttp_stubs.py b/vcr/stubs/aiohttp_stubs.py index 7d2497c..6614cc4 100644 --- a/vcr/stubs/aiohttp_stubs.py +++ b/vcr/stubs/aiohttp_stubs.py @@ -75,7 +75,13 @@ def build_response(vcr_request, vcr_response, history): # cookies for hdr in response.headers.getall(hdrs.SET_COOKIE, ()): try: - response.cookies.load(hdr) + cookies = SimpleCookie(hdr) + for cookie_name, cookie in cookies.items(): + expires = cookie.get('expires', '').strip() + if expires: + log.debug("Ignoring expiration date: %s=\"%s\"", cookie_name, expires) + cookie['expires'] = '' + response.cookies.load(cookie.output(header='').strip()) except CookieError as exc: log.warning("Can not load response cookies: %s", exc)