| 123 | |
| 124 | |
| 125 | async def echo_body(scope: Scope, receive: Receive, send: Send) -> None: |
| 126 | body = b"" |
| 127 | more_body = True |
| 128 | |
| 129 | while more_body: |
| 130 | message = await receive() |
| 131 | body += message.get("body", b"") |
| 132 | more_body = message.get("more_body", False) |
| 133 | |
| 134 | await send( |
| 135 | { |
| 136 | "type": "http.response.start", |
| 137 | "status": 200, |
| 138 | "headers": [[b"content-type", b"text/plain"]], |
| 139 | } |
| 140 | ) |
| 141 | await send({"type": "http.response.body", "body": body}) |
| 142 | |
| 143 | |
| 144 | async def echo_binary(scope: Scope, receive: Receive, send: Send) -> None: |