Skip to content

Request method for retrieving the unparsed request body #897

@simonw

Description

@simonw

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))

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions