]> git.pld-linux.org Git - packages/python3-aiohttp.git/blob - python3-aiohttp-brotli.patch
- new
[packages/python3-aiohttp.git] / python3-aiohttp-brotli.patch
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)
5
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.
8 ---
9  CHANGES/3803.feature       |  1 +
10  CONTRIBUTORS.txt           |  1 +
11  aiohttp/http_parser.py     | 22 ++++++++++++++++++++--
12  docs/client_quickstart.rst |  2 +-
13  docs/index.rst             |  2 +-
14  requirements/ci-wheel.txt  |  2 +-
15  setup.py                   |  2 +-
16  tox.ini                    |  2 +-
17  8 files changed, 27 insertions(+), 7 deletions(-)
18  create mode 100644 CHANGES/3803.feature
19
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
22 @@ -810,9 +810,26 @@
23              if not HAS_BROTLI:  # pragma: no cover
24                  raise ContentEncodingError(
25                      "Can not decode content-encoding: brotli (br). "
26 -                    "Please install `brotlipy`"
27 -                )
28 -            self.decompressor = brotli.Decompressor()
29 +                    "Please install `Brotli`")
30 +
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()
37 +
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)
42 +
43 +                def flush(self) -> bytes:
44 +                    if hasattr(self._obj, "flush"):
45 +                        return self._obj.flush()
46 +                    return b""
47 +
48 +            self.decompressor = BrotliDecoder()  # type: Any
49          else:
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
57  decoded for you.
58  
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>`_.
62  
63  JSON Request
64  ============
65 diff --git a/docs/index.rst b/docs/index.rst
66 index aa20a78fe9..56aa7389f6 100644
67 --- a/docs/index.rst
68 +++ b/docs/index.rst
69 @@ -52,7 +52,7 @@ Installing speedups altogether
70  ------------------------------
71  
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!
76  
77  .. code-block:: bash
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
80 @@ -137,7 +137,7 @@
81      extras_require={
82          "speedups": [
83              "aiodns",
84 -            "brotlipy",
85 +            "Brotli",
86              "cchardet",
87          ],
88      },
This page took 0.092574 seconds and 4 git commands to generate.