mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-10 09:35:34 +00:00
Fix content type being passed to aiohttp response stub
This commit is contained in:
@@ -5,7 +5,7 @@ import aiohttp
|
|||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@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)
|
session = aiohttp.ClientSession(loop=loop)
|
||||||
response_ctx = session.request(method, url, **kwargs)
|
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':
|
if output == 'text':
|
||||||
content = yield from response.text()
|
content = yield from response.text()
|
||||||
elif output == 'json':
|
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':
|
elif output == 'raw':
|
||||||
content = yield from response.read()
|
content = yield from response.read()
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class MockClientResponse(ClientResponse):
|
|||||||
|
|
||||||
# TODO: get encoding from header
|
# TODO: get encoding from header
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def json(self, *, encoding='utf-8', loads=json.loads): # NOQA: E999
|
def json(self, *, encoding='utf-8', loads=json.loads, **kwargs): # NOQA: E999
|
||||||
return loads(self._body.decode(encoding))
|
return loads(self._body.decode(encoding))
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|||||||
Reference in New Issue
Block a user