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

Update aiohttp_stub to work with binary content

This commit is contained in:
Allisson Azevedo
2017-06-22 15:12:58 -03:00
parent 47ccddafee
commit c55d976277
3 changed files with 34 additions and 17 deletions

View File

@@ -3,11 +3,13 @@ import aiohttp
@asyncio.coroutine
def aiohttp_request(loop, method, url, as_text, **kwargs):
def aiohttp_request(loop, method, url, output='text', **kwargs):
with aiohttp.ClientSession(loop=loop) as session:
response = yield from session.request(method, url, **kwargs) # NOQA: E999
if as_text:
if output == 'text':
content = yield from response.text() # NOQA: E999
else:
elif output == 'json':
content = yield from response.json() # NOQA: E999
elif output == 'raw':
content = yield from response.read() # NOQA: E999
return response, content