Skip to content
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

Request method for retrieving the unparsed request body #897

Closed
simonw opened this issue Jul 17, 2020 · 1 comment
Closed

Request method for retrieving the unparsed request body #897

simonw opened this issue Jul 17, 2020 · 1 comment

Comments

@simonw
Copy link
Owner

simonw commented Jul 17, 2020

I'm writing a plugin (simonw/datasette-insert#2) that implements an API for inserting JSON data. As such, I'd like to POST a JSON blob rather than using key=value form encoded data.

Right now there's a request.post_vars() method but no request.post_body() one:

async def post_vars(self):
body = []
body = b""
more_body = True
while more_body:
message = await self.receive()
assert message["type"] == "http.request", message
body += message.get("body", b"")
more_body = message.get("more_body", False)
return dict(parse_qsl(body.decode("utf-8"), keep_blank_values=True))

@simonw
Copy link
Owner Author

simonw commented Jul 17, 2020

simonw added a commit that referenced this issue Aug 9, 2020
simonw added a commit to simonw/datasette-insert that referenced this issue Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant