Decodes body based on the current Content-Encoding header, then removes the header. If the message body is missing or empty, no action is taken. *Raises:* - `ValueError`, when the content-encoding is invalid and strict is True.
(self, strict: bool = True)
| 463 | self.data.timestamp_end = timestamp_end |
| 464 | |
| 465 | def decode(self, strict: bool = True) -> None: |
| 466 | """ |
| 467 | Decodes body based on the current Content-Encoding header, then |
| 468 | removes the header. |
| 469 | |
| 470 | If the message body is missing or empty, no action is taken. |
| 471 | |
| 472 | *Raises:* |
| 473 | - `ValueError`, when the content-encoding is invalid and strict is True. |
| 474 | """ |
| 475 | if not self.raw_content: |
| 476 | # The body is missing (for example, because of body streaming or because it's a response |
| 477 | # to a HEAD request), so we can't correctly update content-length. |
| 478 | return |
| 479 | decoded = self.get_content(strict) |
| 480 | self.headers.pop("content-encoding", None) |
| 481 | self.content = decoded |
| 482 | |
| 483 | def encode(self, encoding: str) -> None: |
| 484 | """ |