From 72fe4c4bdc7172bb6d730535a32a8e6121da1d0a Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Mon, 17 Jul 2017 16:55:03 -0700 Subject: [PATCH 01/14] work on feature to disable automatic response body decompression --- aiohttp/_http_parser.pyx | 10 ++++++---- aiohttp/client.py | 6 ++++-- aiohttp/client_proto.py | 6 ++++-- aiohttp/client_reqrep.py | 12 ++++++++---- aiohttp/http_parser.py | 18 ++++++++++++------ changes/TBD.feature | 1 + docs/client_reference.rst | 7 ++++++- 7 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 changes/TBD.feature diff --git a/aiohttp/_http_parser.pyx b/aiohttp/_http_parser.pyx index 4af5d20d21f..0e08c6c2ae4 100644 --- a/aiohttp/_http_parser.pyx +++ b/aiohttp/_http_parser.pyx @@ -80,7 +80,7 @@ cdef class HttpParser: object protocol, object loop, object timer=None, size_t max_line_size=8190, size_t max_headers=32768, size_t max_field_size=8190, payload_exception=None, - response_with_body=True): + response_with_body=True, auto_decompress=True): cparser.http_parser_init(self._cparser, mode) self._cparser.data = self self._cparser.content_length = 0 @@ -106,6 +106,7 @@ cdef class HttpParser: self._max_field_size = max_field_size self._response_with_body = response_with_body self._upgraded = False + self._auto_decompress = auto_decompress self._csettings.on_url = cb_on_url self._csettings.on_status = cb_on_status @@ -194,7 +195,7 @@ cdef class HttpParser: payload = EMPTY_PAYLOAD self._payload = payload - if encoding is not None: + if encoding is not None and self._auto_decompress: self._payload = DeflateBuffer(payload, encoding) if not self._response_with_body: @@ -301,10 +302,11 @@ cdef class HttpResponseParserC(HttpParser): def __init__(self, protocol, loop, timer=None, size_t max_line_size=8190, size_t max_headers=32768, size_t max_field_size=8190, payload_exception=None, - response_with_body=True, read_until_eof=False): + response_with_body=True, read_until_eof=False, + auto_decompress=True): self._init(cparser.HTTP_RESPONSE, protocol, loop, timer, max_line_size, max_headers, max_field_size, - payload_exception, response_with_body) + payload_exception, response_with_body, auto_decompress) cdef int cb_on_message_begin(cparser.http_parser* parser) except -1: diff --git a/aiohttp/client.py b/aiohttp/client.py index 4f3dad59de8..45b0468a8ce 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -54,7 +54,8 @@ def __init__(self, *, connector=None, loop=None, cookies=None, ws_response_class=ClientWebSocketResponse, version=http.HttpVersion11, cookie_jar=None, connector_owner=True, raise_for_status=False, - read_timeout=sentinel, conn_timeout=None): + read_timeout=sentinel, conn_timeout=None, + auto_decompress=True): implicit_loop = False if loop is None: @@ -102,6 +103,7 @@ def __init__(self, *, connector=None, loop=None, cookies=None, else DEFAULT_TIMEOUT) self._conn_timeout = conn_timeout self._raise_for_status = raise_for_status + self._auto_decompress = auto_decompress # Convert to list of tuples if headers: @@ -223,7 +225,7 @@ def _request(self, method, url, *, expect100=expect100, loop=self._loop, response_class=self._response_class, proxy=proxy, proxy_auth=proxy_auth, timer=timer, - session=self) + session=self, auto_decompress=self._auto_decompress) # connection timeout try: diff --git a/aiohttp/client_proto.py b/aiohttp/client_proto.py index 1a0baa3fd8d..09f875807f1 100644 --- a/aiohttp/client_proto.py +++ b/aiohttp/client_proto.py @@ -128,14 +128,16 @@ def set_parser(self, parser, payload): def set_response_params(self, *, timer=None, skip_payload=False, skip_status_codes=(), - read_until_eof=False): + read_until_eof=False, + auto_decompress=True): self._skip_payload = skip_payload self._skip_status_codes = skip_status_codes self._read_until_eof = read_until_eof self._parser = HttpResponseParser( self, self._loop, timer=timer, payload_exception=ClientPayloadError, - read_until_eof=read_until_eof) + read_until_eof=read_until_eof, + auto_decompress=auto_decompress) if self._tail: data, self._tail = self._tail, b'' diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 3fa52de8d52..c15959f360e 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -66,7 +66,7 @@ def __init__(self, method, url, *, chunked=None, expect100=False, loop=None, response_class=None, proxy=None, proxy_auth=None, proxy_from_env=False, - timer=None, session=None): + timer=None, session=None, auto_decompress=True): if loop is None: loop = asyncio.get_event_loop() @@ -88,6 +88,7 @@ def __init__(self, method, url, *, self.length = None self.response_class = response_class or ClientResponse self._timer = timer if timer is not None else TimerNoop() + self._auto_decompress = auto_decompress if loop.get_debug(): self._source_traceback = traceback.extract_stack(sys._getframe(1)) @@ -406,7 +407,8 @@ def send(self, conn): self.response = self.response_class( self.method, self.original_url, writer=self._writer, continue100=self._continue, timer=self._timer, - request_info=self.request_info + request_info=self.request_info, + auto_decompress=self._auto_decompress ) self.response._post_init(self.loop, self._session) @@ -450,7 +452,7 @@ class ClientResponse(HeadersMixin): def __init__(self, method, url, *, writer=None, continue100=None, timer=None, - request_info=None): + request_info=None, auto_decompress=True): assert isinstance(url, URL) self.method = method @@ -465,6 +467,7 @@ def __init__(self, method, url, *, self._history = () self._request_info = request_info self._timer = timer if timer is not None else TimerNoop() + self._auto_decompress=auto_decompress @property def url(self): @@ -550,7 +553,8 @@ def start(self, connection, read_until_eof=False): timer=self._timer, skip_payload=self.method.lower() == 'head', skip_status_codes=(204, 304), - read_until_eof=read_until_eof) + read_until_eof=read_until_eof, + auto_decompress=self._auto_decompress) with self._timer: while True: diff --git a/aiohttp/http_parser.py b/aiohttp/http_parser.py index c2fb6819229..7904a2c4e77 100644 --- a/aiohttp/http_parser.py +++ b/aiohttp/http_parser.py @@ -59,7 +59,8 @@ def __init__(self, protocol=None, loop=None, max_line_size=8190, max_headers=32768, max_field_size=8190, timer=None, code=None, method=None, readall=False, payload_exception=None, - response_with_body=True, read_until_eof=False): + response_with_body=True, read_until_eof=False, + auto_decompress=True): self.protocol = protocol self.loop = loop self.max_line_size = max_line_size @@ -78,6 +79,7 @@ def __init__(self, protocol=None, loop=None, self._upgraded = False self._payload = None self._payload_parser = None + self._auto_decompress=auto_decompress def feed_eof(self): if self._payload_parser is not None: @@ -162,7 +164,8 @@ def feed_data(self, data, chunked=msg.chunked, method=method, compression=msg.compression, code=self.code, readall=self.readall, - response_with_body=self.response_with_body) + response_with_body=self.response_with_body, + auto_decompress=self._auto_decompress) if not payload_parser.done: self._payload_parser = payload_parser elif method == METH_CONNECT: @@ -171,7 +174,8 @@ def feed_data(self, data, self._upgraded = True self._payload_parser = HttpPayloadParser( payload, method=msg.method, - compression=msg.compression, readall=True) + compression=msg.compression, readall=True, + auto_decompress=self._auto_decompress) else: if (getattr(msg, 'code', 100) >= 199 and length is None and self.read_until_eof): @@ -182,7 +186,8 @@ def feed_data(self, data, chunked=msg.chunked, method=method, compression=msg.compression, code=self.code, readall=True, - response_with_body=self.response_with_body) + response_with_body=self.response_with_body, + auto_decompress=self._auto_decompress) if not payload_parser.done: self._payload_parser = payload_parser else: @@ -432,7 +437,7 @@ class HttpPayloadParser: def __init__(self, payload, length=None, chunked=False, compression=None, code=None, method=None, - readall=False, response_with_body=True): + readall=False, response_with_body=True, auto_decompress=True): self.payload = payload self._length = 0 @@ -440,10 +445,11 @@ def __init__(self, payload, self._chunk = ChunkState.PARSE_CHUNKED_SIZE self._chunk_size = 0 self._chunk_tail = b'' + self._auto_decompress = auto_decompress self.done = False # payload decompression wrapper - if (response_with_body and compression): + if response_with_body and compression and self._auto_decompress: payload = DeflateBuffer(payload, compression) # payload parser diff --git a/changes/TBD.feature b/changes/TBD.feature new file mode 100644 index 00000000000..31323a4a7d7 --- /dev/null +++ b/changes/TBD.feature @@ -0,0 +1 @@ +add ability to disable automatic response decompression \ No newline at end of file diff --git a/docs/client_reference.rst b/docs/client_reference.rst index c7925537d62..a0da3706a61 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -47,7 +47,8 @@ The client session supports the context manager protocol for self closing. version=aiohttp.HttpVersion11, \ cookie_jar=None, read_timeout=None, \ conn_timeout=None, \ - raise_for_status=False) + raise_for_status=False, + auto_decompress=True) The class for creating client sessions and making requests. @@ -129,6 +130,10 @@ The client session supports the context manager protocol for self closing. .. versionchanged:: 1.0 + :param bool auto_decompress: Automatically decompress response body + + .. versionchanged:: 2.x + ``.cookies`` attribute was dropped. Use :attr:`cookie_jar` instead. From 201cfc3615294aaa454ee881ccfda77dc9264836 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Mon, 17 Jul 2017 17:02:06 -0700 Subject: [PATCH 02/14] add a missing folder to clean --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 19021813b70..832ee53c4a9 100644 --- a/Makefile +++ b/Makefile @@ -104,6 +104,7 @@ clean: @rm -f .develop @rm -f .flake @rm -f .install-deps + @rm -rf aiohttp.egg-info doc: @make -C docs html SPHINXOPTS="-W -E" From 115e414a423b25f9d1fa267a9187f4dad5bf4ee1 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Mon, 17 Jul 2017 18:02:14 -0700 Subject: [PATCH 03/14] bugfix --- aiohttp/_http_parser.pyx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aiohttp/_http_parser.pyx b/aiohttp/_http_parser.pyx index 0e08c6c2ae4..34f6c8c87d6 100644 --- a/aiohttp/_http_parser.pyx +++ b/aiohttp/_http_parser.pyx @@ -57,7 +57,8 @@ cdef class HttpParser: object _payload bint _payload_error object _payload_exception - object _last_error + object _last_error + bint _auto_decompress Py_buffer py_buf From 5559504ed210f271124aaa6255c87c0c1e2d32ec Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Mon, 17 Jul 2017 18:02:52 -0700 Subject: [PATCH 04/14] rename --- changes/{TBD.feature => 2110.feature} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changes/{TBD.feature => 2110.feature} (100%) diff --git a/changes/TBD.feature b/changes/2110.feature similarity index 100% rename from changes/TBD.feature rename to changes/2110.feature From 109c229200d7d0a851d1bb947e75841b7ad91d2d Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Mon, 17 Jul 2017 18:18:11 -0700 Subject: [PATCH 05/14] add unittests --- tests/test_test_utils.py | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index 916188f665a..90500693989 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -1,4 +1,5 @@ import asyncio +import gzip from unittest import mock import pytest @@ -15,11 +16,14 @@ def _create_example_app(): - @asyncio.coroutine def hello(request): return web.Response(body=b"Hello, world") + @asyncio.coroutine + def gzip_hello(request): + return web.Response(body=gzip.compress(b"Hello, world"), headers={'Content-Encoding': 'gzip'}) + @asyncio.coroutine def websocket_handler(request): @@ -42,6 +46,7 @@ def cookie_handler(request): app = web.Application() app.router.add_route('*', '/', hello) + app.router.add_route('*', '/gzip_hello', gzip_hello) app.router.add_route('*', '/websocket', websocket_handler) app.router.add_route('*', '/cookie', cookie_handler) return app @@ -63,6 +68,38 @@ def test_get_route(): loop.run_until_complete(test_get_route()) +def test_auto_gzip_decompress(): + with loop_context() as loop: + app = _create_example_app() + with _TestClient(app, loop=loop) as client: + + @asyncio.coroutine + def test_get_route(): + nonlocal client + resp = yield from client.request("GET", "/gzip_hello") + assert resp.status == 200 + data = yield from resp.read() + assert data == b"Hello, world" + + loop.run_until_complete(test_get_route()) + + +def test_noauto_gzip_decompress(): + with loop_context() as loop: + app = _create_example_app() + with _TestClient(app, loop=loop, auto_decompress=False) as client: + + @asyncio.coroutine + def test_get_route(): + nonlocal client + resp = yield from client.request("GET", "/") + assert resp.status == 200 + data = yield from resp.read() + assert data == gzip.compress(b"Hello, world") + + loop.run_until_complete(test_get_route()) + + def test_server_with_create_test_teardown(): with loop_context() as loop: app = _create_example_app() From 5f025a4139fc3358e3831761e9323bbe71a1fa34 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Mon, 17 Jul 2017 18:28:03 -0700 Subject: [PATCH 06/14] flake fixes --- aiohttp/client_reqrep.py | 2 +- aiohttp/http_parser.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index c15959f360e..b9d07375127 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -467,7 +467,7 @@ def __init__(self, method, url, *, self._history = () self._request_info = request_info self._timer = timer if timer is not None else TimerNoop() - self._auto_decompress=auto_decompress + self._auto_decompress = auto_decompress @property def url(self): diff --git a/aiohttp/http_parser.py b/aiohttp/http_parser.py index 7904a2c4e77..eb6f0fd141a 100644 --- a/aiohttp/http_parser.py +++ b/aiohttp/http_parser.py @@ -79,7 +79,7 @@ def __init__(self, protocol=None, loop=None, self._upgraded = False self._payload = None self._payload_parser = None - self._auto_decompress=auto_decompress + self._auto_decompress = auto_decompress def feed_eof(self): if self._payload_parser is not None: From 406db0aadf16af22485394bc21dd37ff382e2dde Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Mon, 17 Jul 2017 18:47:52 -0700 Subject: [PATCH 07/14] another pep fix --- tests/test_test_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index 90500693989..58c8df3dccd 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -22,7 +22,8 @@ def hello(request): @asyncio.coroutine def gzip_hello(request): - return web.Response(body=gzip.compress(b"Hello, world"), headers={'Content-Encoding': 'gzip'}) + return web.Response(body=gzip.compress(b"Hello, world"), + headers={'Content-Encoding': 'gzip'}) @asyncio.coroutine def websocket_handler(request): From 7f451efc2473a1ec4550483876718a692e341d40 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Mon, 17 Jul 2017 19:25:14 -0700 Subject: [PATCH 08/14] fix unittest --- tests/test_test_utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index 58c8df3dccd..77ae7c37528 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -15,6 +15,9 @@ teardown_test_loop, unittest_run_loop) +_hello_world_gz = gzip.compress(b"Hello, world") + + def _create_example_app(): @asyncio.coroutine def hello(request): @@ -22,7 +25,7 @@ def hello(request): @asyncio.coroutine def gzip_hello(request): - return web.Response(body=gzip.compress(b"Hello, world"), + return web.Response(body=_hello_world_gz, headers={'Content-Encoding': 'gzip'}) @asyncio.coroutine @@ -93,10 +96,10 @@ def test_noauto_gzip_decompress(): @asyncio.coroutine def test_get_route(): nonlocal client - resp = yield from client.request("GET", "/") + resp = yield from client.request("GET", "/gzip_hello") assert resp.status == 200 data = yield from resp.read() - assert data == gzip.compress(b"Hello, world") + assert data == _hello_world_gz loop.run_until_complete(test_get_route()) From 1e482da6614eb8d5d67a5dad9045027fe1e002a9 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Mon, 17 Jul 2017 19:27:52 -0700 Subject: [PATCH 09/14] use constants --- tests/test_test_utils.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index 77ae7c37528..8ba38cbc4bc 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -15,13 +15,15 @@ teardown_test_loop, unittest_run_loop) -_hello_world_gz = gzip.compress(b"Hello, world") +_hellow_world_str = "Hello, world" +_hellow_world_bytes = _hellow_world_str.encode('utf-8') +_hello_world_gz = gzip.compress(_hellow_world_bytes) def _create_example_app(): @asyncio.coroutine def hello(request): - return web.Response(body=b"Hello, world") + return web.Response(body=_hellow_world_bytes) @asyncio.coroutine def gzip_hello(request): @@ -44,7 +46,7 @@ def websocket_handler(request): @asyncio.coroutine def cookie_handler(request): - resp = web.Response(body=b"Hello, world") + resp = web.Response(body=_hellow_world_bytes) resp.set_cookie('cookie', 'val') return resp @@ -67,7 +69,7 @@ def test_get_route(): resp = yield from client.request("GET", "/") assert resp.status == 200 text = yield from resp.text() - assert "Hello, world" in text + assert _hellow_world_str == text loop.run_until_complete(test_get_route()) @@ -83,7 +85,7 @@ def test_get_route(): resp = yield from client.request("GET", "/gzip_hello") assert resp.status == 200 data = yield from resp.read() - assert data == b"Hello, world" + assert data == _hellow_world_bytes loop.run_until_complete(test_get_route()) @@ -114,7 +116,7 @@ def test_get_route(): resp = yield from client.request("GET", "/") assert resp.status == 200 text = yield from resp.text() - assert "Hello, world" in text + assert _hellow_world_str == text loop.run_until_complete(test_get_route()) @@ -143,7 +145,7 @@ def test_example_with_loop(self): request = yield from self.client.request("GET", "/") assert request.status == 200 text = yield from request.text() - assert "Hello, world" in text + assert _hellow_world_str == text def test_example(self): @asyncio.coroutine @@ -151,7 +153,7 @@ def test_get_route(): resp = yield from self.client.request("GET", "/") assert resp.status == 200 text = yield from resp.text() - assert "Hello, world" in text + assert _hellow_world_str == text self.loop.run_until_complete(test_get_route()) @@ -182,7 +184,7 @@ def test_get_route(): resp = yield from test_client.request("GET", "/") assert resp.status == 200 text = yield from resp.text() - assert "Hello, world" in text + assert _hellow_world_str == text loop.run_until_complete(test_get_route()) @@ -217,7 +219,7 @@ def test_test_client_methods(method, loop, test_client): resp = yield from getattr(test_client, method)("/") assert resp.status == 200 text = yield from resp.text() - assert "Hello, world" in text + assert _hellow_world_str == text @asyncio.coroutine From 22c8ba769969058198748deeee47c321f1f243a7 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Mon, 17 Jul 2017 19:28:32 -0700 Subject: [PATCH 10/14] fix spelling --- tests/test_test_utils.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index 8ba38cbc4bc..60872d251c2 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -15,15 +15,15 @@ teardown_test_loop, unittest_run_loop) -_hellow_world_str = "Hello, world" -_hellow_world_bytes = _hellow_world_str.encode('utf-8') -_hello_world_gz = gzip.compress(_hellow_world_bytes) +_hello_world_str = "Hello, world" +_hello_world_bytes = _hello_world_str.encode('utf-8') +_hello_world_gz = gzip.compress(_hello_world_bytes) def _create_example_app(): @asyncio.coroutine def hello(request): - return web.Response(body=_hellow_world_bytes) + return web.Response(body=_hello_world_bytes) @asyncio.coroutine def gzip_hello(request): @@ -46,7 +46,7 @@ def websocket_handler(request): @asyncio.coroutine def cookie_handler(request): - resp = web.Response(body=_hellow_world_bytes) + resp = web.Response(body=_hello_world_bytes) resp.set_cookie('cookie', 'val') return resp @@ -69,7 +69,7 @@ def test_get_route(): resp = yield from client.request("GET", "/") assert resp.status == 200 text = yield from resp.text() - assert _hellow_world_str == text + assert _hello_world_str == text loop.run_until_complete(test_get_route()) @@ -85,7 +85,7 @@ def test_get_route(): resp = yield from client.request("GET", "/gzip_hello") assert resp.status == 200 data = yield from resp.read() - assert data == _hellow_world_bytes + assert data == _hello_world_bytes loop.run_until_complete(test_get_route()) @@ -116,7 +116,7 @@ def test_get_route(): resp = yield from client.request("GET", "/") assert resp.status == 200 text = yield from resp.text() - assert _hellow_world_str == text + assert _hello_world_str == text loop.run_until_complete(test_get_route()) @@ -145,7 +145,7 @@ def test_example_with_loop(self): request = yield from self.client.request("GET", "/") assert request.status == 200 text = yield from request.text() - assert _hellow_world_str == text + assert _hello_world_str == text def test_example(self): @asyncio.coroutine @@ -153,7 +153,7 @@ def test_get_route(): resp = yield from self.client.request("GET", "/") assert resp.status == 200 text = yield from resp.text() - assert _hellow_world_str == text + assert _hello_world_str == text self.loop.run_until_complete(test_get_route()) @@ -184,7 +184,7 @@ def test_get_route(): resp = yield from test_client.request("GET", "/") assert resp.status == 200 text = yield from resp.text() - assert _hellow_world_str == text + assert _hello_world_str == text loop.run_until_complete(test_get_route()) @@ -219,7 +219,7 @@ def test_test_client_methods(method, loop, test_client): resp = yield from getattr(test_client, method)("/") assert resp.status == 200 text = yield from resp.text() - assert _hellow_world_str == text + assert _hello_world_str == text @asyncio.coroutine From 2f5754851fd2bebce2a22cb7ab719d1ce01a9b10 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Wed, 26 Jul 2017 20:03:30 +0300 Subject: [PATCH 11/14] Update client_reference.rst Pin version to 2.3 --- docs/client_reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/client_reference.rst b/docs/client_reference.rst index a0da3706a61..450c327e99e 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -132,7 +132,7 @@ The client session supports the context manager protocol for self closing. :param bool auto_decompress: Automatically decompress response body - .. versionchanged:: 2.x + .. versionchanged:: 2.3 ``.cookies`` attribute was dropped. Use :attr:`cookie_jar` instead. From 15030bab296f3793bb460298a7240593fff5c3be Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Wed, 26 Jul 2017 14:54:08 -0700 Subject: [PATCH 12/14] fix unittests --- tests/test_test_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index 7c38a7de0ae..bc5f05f4b63 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -77,7 +77,7 @@ def test_get_route(): def test_auto_gzip_decompress(): with loop_context() as loop: app = _create_example_app() - with _TestClient(app, loop=loop) as client: + with _TestClient(_TestServer(app, loop=loop), loop=loop) as client: @asyncio.coroutine def test_get_route(): @@ -93,7 +93,7 @@ def test_get_route(): def test_noauto_gzip_decompress(): with loop_context() as loop: app = _create_example_app() - with _TestClient(app, loop=loop, auto_decompress=False) as client: + with _TestClient(_TestServer(app, loop=loop), auto_decompress=False) as client: @asyncio.coroutine def test_get_route(): From 7a9240a2c20d815aa54365d1d3d235d930e831c7 Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Thu, 27 Jul 2017 09:29:50 -0700 Subject: [PATCH 13/14] fix test --- tests/test_test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index bc5f05f4b63..1cca13829eb 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -93,7 +93,7 @@ def test_get_route(): def test_noauto_gzip_decompress(): with loop_context() as loop: app = _create_example_app() - with _TestClient(_TestServer(app, loop=loop), auto_decompress=False) as client: + with _TestClient(_TestServer(app, loop=loop), loop=loop, auto_decompress=False) as client: @asyncio.coroutine def test_get_route(): From 75f78142007dd0807a07be7af75153e4b2815a4b Mon Sep 17 00:00:00 2001 From: Alexander Mohr Date: Thu, 27 Jul 2017 10:18:14 -0700 Subject: [PATCH 14/14] pep --- tests/test_test_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_test_utils.py b/tests/test_test_utils.py index 1cca13829eb..621970b4154 100644 --- a/tests/test_test_utils.py +++ b/tests/test_test_utils.py @@ -93,7 +93,8 @@ def test_get_route(): def test_noauto_gzip_decompress(): with loop_context() as loop: app = _create_example_app() - with _TestClient(_TestServer(app, loop=loop), loop=loop, auto_decompress=False) as client: + with _TestClient(_TestServer(app, loop=loop), loop=loop, + auto_decompress=False) as client: @asyncio.coroutine def test_get_route():