コード例 #1
0
ファイル: test_request.py プロジェクト: gbozee/starlette
 async def asgi(receive, send):
     request = Request(scope, receive)
     body = b""
     async for chunk in request.stream():
         body += chunk
     response = JSONResponse({"body": body.decode()})
     await response(receive, send)
コード例 #2
0
ファイル: test_request.py プロジェクト: gbozee/starlette
 async def asgi(receive, send):
     request = Request(scope)
     try:
         data = await request.json()
     except RuntimeError:
         data = "Receive channel not available"
     response = JSONResponse({"json": data})
     await response(receive, send)
コード例 #3
0
ファイル: test_request.py プロジェクト: gbozee/starlette
 async def asgi(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(receive, send)
コード例 #4
0
ファイル: test_request.py プロジェクト: gbozee/starlette
 async def asgi(receive, send):
     request = Request(scope, receive)
     body = await request.body()
     response = JSONResponse({"body": body.decode()})
     await response(receive, send)
コード例 #5
0
ファイル: test_request.py プロジェクト: gbozee/starlette
 async def asgi(receive, send):
     request = Request(scope, receive)
     data = {"method": request.method, "url": request.url}
     response = JSONResponse(data)
     await response(receive, send)
コード例 #6
0
ファイル: test_request.py プロジェクト: gbozee/starlette
 async def asgi(receive, send):
     request = Request(scope, receive)
     headers = dict(request.headers)
     response = JSONResponse({"headers": headers})
     await response(receive, send)
コード例 #7
0
ファイル: test_request.py プロジェクト: gbozee/starlette
 async def asgi(receive, send):
     request = Request(scope, receive)
     params = dict(request.query_params)
     response = JSONResponse({"params": params})
     await response(receive, send)
コード例 #8
0
ファイル: test_request.py プロジェクト: gbozee/starlette
 async def asgi(receive, send):
     request = Request(scope, receive)
     data = await request.json()
     response = JSONResponse({"json": data})
     await response(receive, send)