-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API to easily send JSON as request body #1726
Comments
Tornado automatically makes
This will match how the |
we can add payload for dict and list, something like https://github.com/aio-libs/aiohttp/blob/master/aiohttp/payload.py#L199 I'd add "json=" and "text=" but we should be very careful, |
discord.py can request json like so (They basically made a class that creates their own import aiohttp
import asyncio
import json
class HTTPClient:
def __init__(self, loop, *args, *kwargs):
self.loop = loop
self.session = aiohttp.ClientSession(loop=self.loop, *args, **kwargs)
@asyncio.coroutine
def request(self, url, method, **kwargs):
if 'json' in kwargs:
headers['Content-Type'] = 'application/json'
kwargs['headers'] = headers
kwargs['data'] = json.dumps(kwargs.pop('json'), separators=(',', ':'), ensure_ascii=True)
r = yield from self.session.request(method, url, **kwargs)
yield from r.release() As you can see json can be passed just fine into |
added |
Great! I have now more reasons to throw out Tornado from our projects! |
previous discussion about json in |
added separate ticket for web.Response |
i.e. some shortcut for
The text was updated successfully, but these errors were encountered: