Beispiel #1
0
 def app(environ, start_response):
     request = Request(environ)
     body = b""
     for chunk in request.stream():
         body += chunk
     response = PlainTextResponse(body)
     return response(environ, start_response)
Beispiel #2
0
 def app(environ, start_response):
     request = Request(environ)
     body = request.body
     chunks = b""
     for chunk in request.stream():
         chunks += chunk
     response = JSONResponse({
         "body": body.decode(),
         "stream": chunks.decode()
     })
     return response(environ, start_response)
Beispiel #3
0
 def app(environ, start_response):
     request = Request(environ)
     chunks = b""
     for chunk in request.stream():
         chunks += chunk
     try:
         body = request.body
     except RuntimeError:
         body = b"<stream consumed>"
     response = JSONResponse({
         "body": body.decode(),
         "stream": chunks.decode()
     })
     return response(environ, start_response)