Decodes data according the specified `Content-Encoding` or `Content-Transfer-Encoding` headers value. Supports ``gzip``, ``deflate`` and ``identity`` encodings for `Content-Encoding` header. Supports ``base64``, ``quoted-printable`` encodings for `Content-Tr
(self, data)
| 433 | return self._at_eof |
| 434 | |
| 435 | def decode(self, data): |
| 436 | """Decodes data according the specified `Content-Encoding` |
| 437 | or `Content-Transfer-Encoding` headers value. |
| 438 | |
| 439 | Supports ``gzip``, ``deflate`` and ``identity`` encodings for |
| 440 | `Content-Encoding` header. |
| 441 | |
| 442 | Supports ``base64``, ``quoted-printable`` encodings for |
| 443 | `Content-Transfer-Encoding` header. |
| 444 | |
| 445 | :param bytearray data: Data to decode. |
| 446 | |
| 447 | :raises: :exc:`RuntimeError` - if encoding is unknown. |
| 448 | |
| 449 | :rtype: bytes |
| 450 | """ |
| 451 | if CONTENT_TRANSFER_ENCODING in self.headers: |
| 452 | data = self._decode_content_transfer(data) |
| 453 | if CONTENT_ENCODING in self.headers: |
| 454 | return self._decode_content(data) |
| 455 | return data |
| 456 | |
| 457 | def _decode_content(self, data): |
| 458 | encoding = self.headers[CONTENT_ENCODING].lower() |