| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ddce7e5 commit 57405e9
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -711,7 +711,7 @@ def __init__(self, checksum): | |||
| 711 | 711 | super().__init__() | |
| 712 | 712 | self._checksum = checksum | |
| 713 | 713 | ||
| 714 | - def decompress(self, data): | ||
| 714 | + def decompress(self, data, max_length=-1): | ||
| 715 | 715 | """Decompress the bytes. | |
| 716 | 716 | ||
| 717 | 717 | Args: | |
@@ -721,7 +721,11 @@ def decompress(self, data): | |||
| 721 | 721 | bytes: The decompressed bytes from ``data``. | |
| 722 | 722 | """ | |
| 723 | 723 | self._checksum.update(data) | |
| 724 | - return super().decompress(data) | ||
| 724 | + try: | ||
| 725 | + return super().decompress(data, max_length=max_length) | ||
| 726 | + except TypeError: | ||
| 727 | + # Fallback for urllib3 < 2.6.0 which lacks `max_length` support. | ||
| 728 | + return super().decompress(data) | ||
| 725 | 729 | ||
| 726 | 730 | ||
| 727 | 731 | # urllib3.response.BrotliDecoder might not exist depending on whether brotli is | |
@@ -747,7 +751,7 @@ def __init__(self, checksum): | |||
| 747 | 751 | self._decoder = urllib3.response.BrotliDecoder() | |
| 748 | 752 | self._checksum = checksum | |
| 749 | 753 | ||
| 750 | - def decompress(self, data): | ||
| 754 | + def decompress(self, data, max_length=-1): | ||
| 751 | 755 | """Decompress the bytes. | |
| 752 | 756 | ||
| 753 | 757 | Args: | |
@@ -757,10 +761,19 @@ def decompress(self, data): | |||
| 757 | 761 | bytes: The decompressed bytes from ``data``. | |
| 758 | 762 | """ | |
| 759 | 763 | self._checksum.update(data) | |
| 760 | - return self._decoder.decompress(data) | ||
| 764 | + try: | ||
| 765 | + return self._decoder.decompress(data, max_length=max_length) | ||
| 766 | + except TypeError: | ||
| 767 | + # Fallback for urllib3 < 2.6.0 which lacks `max_length` support. | ||
| 768 | + return self._decoder.decompress(data) | ||
| 761 | 769 | ||
| 762 | 770 | def flush(self): | |
| 763 | 771 | return self._decoder.flush() | |
| 764 | 772 | ||
| 773 | + @property | ||
| 774 | + def has_unconsumed_tail(self) -> bool: | ||
| 775 | + return self._decoder.has_unconsumed_tail | ||
| 776 | + | ||
| 777 | + | ||
| 765 | 778 | else: # pragma: NO COVER | |
| 766 | 779 | _BrotliDecoder = None # type: ignore # pragma: NO COVER | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,4 +7,3 @@ grpcio | |||
| 7 | 7 | proto-plus | |
| 8 | 8 | protobuf | |
| 9 | 9 | grpc-google-iam-v1 | |
| 10 | - urllib3==2.5.0 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments