Repository: aio-libs/aiohttp

Issue:
option to disable automatic client response body decompression
enhancement for https://github.com/aio-libs/aiohttp/issues/1992


Discussion:
this PR only handles ClientResponse, other functionality can be added in separate PRs
# [Codecov](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=h1) Report
> Merging [#2110](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=desc) into [master](https://codecov.io/gh/aio-libs/aiohttp/commit/91dc5b7e3f757f062dd84ed3593971a16afb5efd?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/aio-libs/aiohttp/pull/2110/graphs/tree.svg?height=150&width=650&token=LJn22G3rd7&src=pr)](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #2110      +/-   ##
==========================================
+ Coverage   97.07%   97.07%   +<.01%     
==========================================
  Files          38       38              
  Lines        7723     7733      +10     
  Branches     1346     1347       +1     
==========================================
+ Hits         7497     7507      +10     
  Misses        102      102              
  Partials      124      124
```


| [Impacted Files](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [aiohttp/client\_proto.py](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree#diff-YWlvaHR0cC9jbGllbnRfcHJvdG8ucHk=) | `91.66% <ø> (ø)` | :arrow_up: |
| [aiohttp/client\_reqrep.py](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree#diff-YWlvaHR0cC9jbGllbnRfcmVxcmVwLnB5) | `97.2% <100%> (+0.01%)` | :arrow_up: |
| [aiohttp/http\_parser.py](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree#diff-YWlvaHR0cC9odHRwX3BhcnNlci5weQ==) | `97.25% <100%> (+0.01%)` | :arrow_up: |
| [aiohttp/web\_urldispatcher.py](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree#diff-YWlvaHR0cC93ZWJfdXJsZGlzcGF0Y2hlci5weQ==) | `99.42% <0%> (ø)` | :arrow_up: |
| [aiohttp/client\_exceptions.py](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree#diff-YWlvaHR0cC9jbGllbnRfZXhjZXB0aW9ucy5weQ==) | `100% <0%> (ø)` | :arrow_up: |
| [aiohttp/web.py](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree#diff-YWlvaHR0cC93ZWIucHk=) | `99.65% <0%> (ø)` | :arrow_up: |
| [aiohttp/test\_utils.py](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree#diff-YWlvaHR0cC90ZXN0X3V0aWxzLnB5) | `98.6% <0%> (ø)` | :arrow_up: |
| [tests/autobahn/client.py](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree#diff-dGVzdHMvYXV0b2JhaG4vY2xpZW50LnB5) | `96.85% <0%> (ø)` | :arrow_up: |
| [aiohttp/web\_request.py](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=tree#diff-YWlvaHR0cC93ZWJfcmVxdWVzdC5weQ==) | `98.94% <0%> (+0.01%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=footer). Last update [91dc5b7...75f7814](https://codecov.io/gh/aio-libs/aiohttp/pull/2110?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Is this too fine grained? Should it be just "disable all incoming stream transformations" setting?
Good note!
Do you object parameter name, isn't it?
right now aiohttp applies two type of transformation, `transfer-encoding` and `content-encoding`.
I'd disable both with one parameter.
Makes sense.
@cecton could you take a look on failed tests?
Sure they could accept `loop` fixture explicitly but I worry about backward degradation in our test tools.
Looks like the PR was passed without errors unless I've merged your changes into master.
ya I think botocore may need transfer-encoding disabled as well.  I'll try working on that today.
@fafhrd91 @asvetlov are there any aiohttp examples of client/server gzip transfer encoding?  I don't see any tests or examples in the web.
what do you mean by example?  implementation is shared between client and server, 
http_parser.DeflateBuffer and http_writer.PayloadWriter for reading and for writing
Thanks!
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a [new issue] for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that [new issue].

[new issue]: https://github.com/aio-libs/aiohttp/issues/new

Resolving patch:
diff --git a/aiohttp/resolver.py b/aiohttp/resolver.py
--- a/aiohttp/resolver.py
+++ b/aiohttp/resolver.py
@@ -26,10 +26,10 @@ def __init__(self, loop: Optional[asyncio.AbstractEventLoop] = None) -> None:
         self._loop = get_running_loop(loop)
 
     async def resolve(
-        self, host: str, port: int = 0, family: int = socket.AF_INET
+        self, hostname: str, port: int = 0, family: int = socket.AF_INET
     ) -> List[Dict[str, Any]]:
         infos = await self._loop.getaddrinfo(
-            host, port, type=socket.SOCK_STREAM, family=family
+            hostname, port, type=socket.SOCK_STREAM, family=family
         )
 
         hosts = []
@@ -46,7 +46,7 @@ async def resolve(
                 host, port = address[:2]
             hosts.append(
                 {
-                    "hostname": host,
+                    "hostname": hostname,
                     "host": host,
                     "port": port,
                     "family": family,


Test patch:
diff --git a/tests/test_connector.py b/tests/test_connector.py
--- a/tests/test_connector.py
+++ b/tests/test_connector.py
@@ -675,10 +675,10 @@ async def test_tcp_connector_resolve_host(loop) -> None:
     for rec in res:
         if rec["family"] == socket.AF_INET:
             assert rec["host"] == "127.0.0.1"
-            assert rec["hostname"] == "127.0.0.1"
+            assert rec["hostname"] == "localhost"
             assert rec["port"] == 8080
         elif rec["family"] == socket.AF_INET6:
-            assert rec["hostname"] == "::1"
+            assert rec["hostname"] == "localhost"
             assert rec["port"] == 8080
             if platform.system() == "Darwin":
                 assert rec["host"] in ("::1", "fe80::1", "fe80::1%lo0")
diff --git a/tests/test_resolver.py b/tests/test_resolver.py
--- a/tests/test_resolver.py
+++ b/tests/test_resolver.py
@@ -130,6 +130,7 @@ async def test_threaded_resolver_positive_lookup() -> None:
     loop.getaddrinfo = fake_addrinfo(["127.0.0.1"])
     resolver = ThreadedResolver(loop=loop)
     real = await resolver.resolve("www.python.org")
+    assert real[0]["hostname"] == "www.python.org"
     ipaddress.ip_address(real[0]["host"])