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

aiohttp: Add response cookies loading

This commit is contained in:
Paulo Romeira
2020-06-03 19:07:58 -03:00
committed by Kevin McCarthy
parent 69e4316545
commit 438550959f

View File

@@ -5,6 +5,8 @@ import logging
import json import json
from aiohttp import ClientConnectionError, ClientResponse, RequestInfo, streams from aiohttp import ClientConnectionError, ClientResponse, RequestInfo, streams
from aiohttp import hdrs
from http.cookies import CookieError
from multidict import CIMultiDict, CIMultiDictProxy from multidict import CIMultiDict, CIMultiDictProxy
from yarl import URL from yarl import URL
@@ -68,6 +70,12 @@ def build_response(vcr_request, vcr_response, history):
response.reason = vcr_response["status"]["message"] response.reason = vcr_response["status"]["message"]
response._headers = _deserialize_headers(vcr_response["headers"]) response._headers = _deserialize_headers(vcr_response["headers"])
response._history = tuple(history) response._history = tuple(history)
# cookies
for hdr in response.headers.getall(hdrs.SET_COOKIE, ()):
try:
response.cookies.load(hdr)
except CookieError as exc:
log.warning('Can not load response cookies: %s', exc)
response.close() response.close()
return response return response