-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
option to disable automatic client response body decompression #2110
option to disable automatic client response body decompression #2110
Conversation
this PR only handles ClientResponse, other functionality can be added in separate PRs |
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Is this too fine grained? Should it be just "disable all incoming stream transformations" setting? |
Good note! |
right now aiohttp applies two type of transformation, |
Makes sense. |
@cecton could you take a look on failed tests? |
tests/test_test_utils.py
Outdated
def test_auto_gzip_decompress(): | ||
with loop_context() as loop: | ||
app = _create_example_app() | ||
with _TestClient(app, loop=loop) as client: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asvetlov Here is the problem. If you really want to use TestClient directly, you need a TestServer instance. It's best to use the test_client
fixture if you can:
def test_auto_gzip_decompress(test_client):
app = _create_example_app()
with test_client(app) as client:
Otherwise:
with loop_context() as loop:
app = _create_example_app()
with _TestClient(_TestServer(app, loop=loop), loop=loop) as client:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no significant degradation.
@thehesiod please update tests to use test_client
fixture explicitly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the tests to run like the tests surrounding it, I can't use test_client
fixture because I use _create_example_app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thehesiod I don't understand the problem. As far as I know you can give the app created by _create_example_app
as argument to test_client
. The fixture gives you a function, not a client instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must have been looking at an old version of that function, in either case all the functions should be updated, so if @asvetlov says ok I can change them all to use this fixture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fixture test_client
won't work... I just realized that this fixture is overridden in the test file itself.
ya I think botocore may need transfer-encoding disabled as well. I'll try working on that today. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small suggestions for readability improvement
resp = yield from client.request("GET", "/gzip_hello") | ||
assert resp.status == 200 | ||
data = yield from resp.read() | ||
assert data == _hello_world_gz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test coroutine is duplicated at a lot of different places. Maybe you can make a helper outside the test and provide the client instance in argument. I think it would be more readable. What do you think?
async def _assertBody(client, url, body):
resp = await ...
assert resp.status == 200
data = await ...
assert data == body
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been avoiding too much refactoring because @asvetlov has frowned upon that in the past in PRs that implement new features. He's wanted these types of changes in multiple PRs. If he gives the go-ahead I can do these suggested changes.
@@ -14,11 +15,20 @@ | |||
teardown_test_loop, unittest_run_loop) | |||
|
|||
|
|||
def _create_example_app(): | |||
_hello_world_str = "Hello, world" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this rate you can even generate a random string. Like:
uuid.uuid4().hex
I would actually even put the str, bytes and gzip inside the app instance:
app = web.Application()
app["body_str"] = uuid.uuid4().hex
app["body_bytes"] = app["body_str"].encode('utf-8')
app["body_gz"] = gzip.compress(app["body_bytes"])
what do you mean by example? implementation is shared between client and server, |
Thanks! |
Fix a variable-shadowing bug causing `ThreadedResolver.resolve` to return the resolved IP as the "hostname" in each record, which prevented validation of HTTPS connections. Fixes aio-libs#2110.
Fix a variable-shadowing bug causing `ThreadedResolver.resolve` to return the resolved IP as the "hostname" in each record, which prevented validation of HTTPS connections. Fixes aio-libs#2110.
Fix a variable-shadowing bug causing `ThreadedResolver.resolve` to return the resolved IP as the "hostname" in each record, which prevented validation of HTTPS connections. Fixes #2110.
Fix a variable-shadowing bug causing `ThreadedResolver.resolve` to return the resolved IP as the "hostname" in each record, which prevented validation of HTTPS connections. Fixes #2110.
enhancement for #1992