mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
14 lines
440 B
Python
14 lines
440 B
Python
import asyncio
|
|
import aiohttp
|
|
|
|
|
|
@asyncio.coroutine
|
|
def aiohttp_request(loop, method, url, as_text, **kwargs):
|
|
with aiohttp.ClientSession(loop=loop) as session:
|
|
response = yield from session.request(method, url, **kwargs) # NOQA: E999
|
|
if as_text:
|
|
content = yield from response.text() # NOQA: E999
|
|
else:
|
|
content = yield from response.json() # NOQA: E999
|
|
return response, content
|