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

Fix content type being passed to aiohttp response stub

This commit is contained in:
Luiz Menezes
2018-07-07 23:56:39 -03:00
parent ab6e6b5b5d
commit 75cb067e29
2 changed files with 4 additions and 3 deletions

View File

@@ -5,7 +5,7 @@ import aiohttp
@asyncio.coroutine
def aiohttp_request(loop, method, url, output='text', encoding='utf-8', **kwargs):
def aiohttp_request(loop, method, url, output='text', encoding='utf-8', content_type=None, **kwargs):
session = aiohttp.ClientSession(loop=loop)
response_ctx = session.request(method, url, **kwargs)
@@ -13,7 +13,8 @@ def aiohttp_request(loop, method, url, output='text', encoding='utf-8', **kwargs
if output == 'text':
content = yield from response.text()
elif output == 'json':
content = yield from response.json(encoding=encoding)
content_type = content_type or 'application/json'
content = yield from response.json(encoding=encoding, content_type=content_type)
elif output == 'raw':
content = yield from response.read()