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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user