| 142 | |
| 143 | |
| 144 | async def echo_binary(scope: Scope, receive: Receive, send: Send) -> None: |
| 145 | body = b"" |
| 146 | more_body = True |
| 147 | |
| 148 | while more_body: |
| 149 | message = await receive() |
| 150 | body += message.get("body", b"") |
| 151 | more_body = message.get("more_body", False) |
| 152 | |
| 153 | await send( |
| 154 | { |
| 155 | "type": "http.response.start", |
| 156 | "status": 200, |
| 157 | "headers": [[b"content-type", b"application/octet-stream"]], |
| 158 | } |
| 159 | ) |
| 160 | await send({"type": "http.response.body", "body": body}) |
| 161 | |
| 162 | |
| 163 | async def echo_headers(scope: Scope, receive: Receive, send: Send) -> None: |