async def app(scope, receive, send): request = Request(scope, receive) body = b"" async for chunk in request.stream(): body += chunk response = JSONResponse({"body": body.decode()}) await response(scope, receive, send)
async def app(scope, receive, send): request = Request(scope, receive) chunks = b"" async for chunk in request.stream(): chunks += chunk try: body = await request.body() except RuntimeError: body = b"<stream consumed>" response = JSONResponse({"body": body.decode(), "stream": chunks.decode()}) await response(scope, receive, send)