diff options
| author | Seth Michael Larson <sethmichaellarson@gmail.com> | 2019-04-24 07:18:44 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-24 07:18:44 -0500 |
| commit | 64e413f1b2fef86a150ae747f00aab0e2be8e59c (patch) | |
| tree | 7cdb0757252b0fa4ba15ff4a89baa43e6f2abad3 /src | |
| parent | ff8f7219d98a4f939260020244d0769bef81b305 (diff) | |
| download | urllib3-64e413f1b2fef86a150ae747f00aab0e2be8e59c.tar.gz | |
Add first-class support for Brotli package (#1579)
Diffstat (limited to 'src')
| -rw-r--r-- | src/urllib3/response.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/urllib3/response.py b/src/urllib3/response.py index b0a80a73..4f857932 100644 --- a/src/urllib3/response.py +++ b/src/urllib3/response.py @@ -97,14 +97,21 @@ class GzipDecoder(object): if brotli is not None: class BrotliDecoder(object): + # Supports both 'brotlipy' and 'Brotli' packages + # since they share an import name. The top branches + # are for 'brotlipy' and bottom branches for 'Brotli' def __init__(self): self._obj = brotli.Decompressor() - def __getattr__(self, name): - return getattr(self._obj, name) - def decompress(self, data): - return self._obj.decompress(data) + if hasattr(self._obj, 'decompress'): + return self._obj.decompress(data) + return self._obj.process(data) + + def flush(self): + if hasattr(self._obj, 'flush'): + return self._obj.flush() + return b'' class MultiDecoder(object): |
