*416* `Requested Range Not Satisfiable` The client asked for an invalid part of the file. .. versionadded:: 0.7
| 522 | |
| 523 | |
| 524 | class RequestedRangeNotSatisfiable(HTTPException): |
| 525 | """*416* `Requested Range Not Satisfiable` |
| 526 | |
| 527 | The client asked for an invalid part of the file. |
| 528 | |
| 529 | .. versionadded:: 0.7 |
| 530 | """ |
| 531 | |
| 532 | code = 416 |
| 533 | description = "The server cannot provide the requested range." |
| 534 | |
| 535 | def __init__( |
| 536 | self, |
| 537 | length: int | None = None, |
| 538 | units: str = "bytes", |
| 539 | description: str | None = None, |
| 540 | response: SansIOResponse | None = None, |
| 541 | ) -> None: |
| 542 | """Takes an optional `Content-Range` header value based on ``length`` |
| 543 | parameter. |
| 544 | """ |
| 545 | super().__init__(description=description, response=response) |
| 546 | self.length = length |
| 547 | self.units = units |
| 548 | |
| 549 | def get_headers( |
| 550 | self, |
| 551 | environ: WSGIEnvironment | None = None, |
| 552 | scope: dict[str, t.Any] | None = None, |
| 553 | ) -> list[tuple[str, str]]: |
| 554 | headers = super().get_headers(environ, scope) |
| 555 | if self.length is not None: |
| 556 | headers.append(("Content-Range", f"{self.units} */{self.length}")) |
| 557 | return headers |
| 558 | |
| 559 | |
| 560 | class ExpectationFailed(HTTPException): |
no outgoing calls
no test coverage detected