| 382 | await self.background() |
| 383 | |
| 384 | async def _handle_simple(self, send: Send, send_header_only: bool, send_pathsend: bool) -> None: |
| 385 | await send({"type": "http.response.start", "status": self.status_code, "headers": self.raw_headers}) |
| 386 | if send_header_only: |
| 387 | await send({"type": "http.response.body", "body": b"", "more_body": False}) |
| 388 | elif send_pathsend: |
| 389 | await send({"type": "http.response.pathsend", "path": str(self.path)}) |
| 390 | else: |
| 391 | async with await anyio.open_file(self.path, mode="rb") as file: |
| 392 | more_body = True |
| 393 | while more_body: |
| 394 | chunk = await file.read(self.chunk_size) |
| 395 | more_body = len(chunk) == self.chunk_size |
| 396 | await send({"type": "http.response.body", "body": chunk, "more_body": more_body}) |
| 397 | |
| 398 | async def _handle_single_range( |
| 399 | self, send: Send, start: int, end: int, file_size: int, send_header_only: bool |