1 From 9afc44b052643213da15c9583ecbd643ca999601 Mon Sep 17 00:00:00 2001
2 From: Felix Yan <felixonmars@archlinux.org>
3 Date: Fri, 19 Jul 2019 21:32:55 +0800
4 Subject: [PATCH] Use Brotli instead of brotlipy (#3803)
6 brotlipy is stuck at brotli 0.6 and upstream is inactive. Let's switch
7 to the official binding which is up-to-date.
9 CHANGES/3803.feature | 1 +
10 CONTRIBUTORS.txt | 1 +
11 aiohttp/http_parser.py | 22 ++++++++++++++++++++--
12 docs/client_quickstart.rst | 2 +-
14 requirements/ci-wheel.txt | 2 +-
17 8 files changed, 27 insertions(+), 7 deletions(-)
18 create mode 100644 CHANGES/3803.feature
20 --- aiohttp-3.7.3/aiohttp/http_parser.py.orig 2021-02-06 22:03:16.853983452 +0100
21 +++ aiohttp-3.7.3/aiohttp/http_parser.py 2021-02-06 22:22:29.544405459 +0100
23 if not HAS_BROTLI: # pragma: no cover
24 raise ContentEncodingError(
25 "Can not decode content-encoding: brotli (br). "
26 - "Please install `brotlipy`"
28 - self.decompressor = brotli.Decompressor()
29 + "Please install `Brotli`")
31 + class BrotliDecoder:
32 + # Supports both 'brotlipy' and 'Brotli' packages
33 + # since they share an import name. The top branches
34 + # are for 'brotlipy' and bottom branches for 'Brotli'
35 + def __init__(self) -> None:
36 + self._obj = brotli.Decompressor()
38 + def decompress(self, data: bytes) -> bytes:
39 + if hasattr(self._obj, "decompress"):
40 + return self._obj.decompress(data)
41 + return self._obj.process(data)
43 + def flush(self) -> bytes:
44 + if hasattr(self._obj, "flush"):
45 + return self._obj.flush()
48 + self.decompressor = BrotliDecoder() # type: Any
50 zlib_mode = 16 + zlib.MAX_WBITS if encoding == "gzip" else zlib.MAX_WBITS
51 self.decompressor = zlib.decompressobj(wbits=zlib_mode)
52 diff --git a/docs/client_quickstart.rst b/docs/client_quickstart.rst
53 index f58eb7166f..1d5d2fb448 100644
54 --- a/docs/client_quickstart.rst
55 +++ b/docs/client_quickstart.rst
56 @@ -171,7 +171,7 @@ The ``gzip`` and ``deflate`` transfer-encodings are automatically
59 You can enable ``brotli`` transfer-encodings support,
60 -just install `brotlipy <https://github.com/python-hyper/brotlipy>`_.
61 +just install `Brotli <https://pypi.org/project/Brotli>`_.
65 diff --git a/docs/index.rst b/docs/index.rst
66 index aa20a78fe9..56aa7389f6 100644
69 @@ -52,7 +52,7 @@ Installing speedups altogether
70 ------------------------------
72 The following will get you ``aiohttp`` along with :term:`chardet`,
73 -:term:`aiodns` and ``brotlipy`` in one bundle. No need to type
74 +:term:`aiodns` and ``Brotli`` in one bundle. No need to type
75 separate commands anymore!
78 --- aiohttp-3.7.3/setup.py.orig 2021-02-06 22:24:15.207166368 +0100
79 +++ aiohttp-3.7.3/setup.py 2021-02-06 22:24:45.976999674 +0100