We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Calling enable_compression on a response does not work as expected at all. The response misses data or the whole handler hangs.
enable_compression
The app below reproduces the problem:
import asyncio import aiohttp.web def run_app(app, host='0.0.0.0', port=8080): """Run an app locally.""" loop = asyncio.get_event_loop() handler = app.make_handler() f = loop.create_server(handler, host, port) srv = loop.run_until_complete(f) if host == '0.0.0.0': host = '127.0.0.1' print(' * Running on http://{host}:{port}/ (Press CTRL+C to quit)'.format( host=host, port=port)) try: loop.run_forever() except KeyboardInterrupt: pass finally: loop.run_until_complete(handler.finish_connections(1.0)) srv.close() loop.run_until_complete(srv.wait_closed()) loop.run_until_complete(app.finish()) loop.close() @asyncio.coroutine def bug_response_small(unused_request): r = aiohttp.web.Response(body=b'foo') r.enable_compression() return r @asyncio.coroutine def bug_response_large(unused_request): r = aiohttp.web.Response(body=b'foo' * 100) r.enable_compression() return r if __name__ == '__main__': app = aiohttp.web.Application() app.router.add_route('GET', '/response/small', bug_response_small) app.router.add_route('GET', '/response/large', bug_response_large) run_app(app)
Run the app and then execute the following:
~$ curl localhost:8080/response/small -H "Accept-Encoding: none" --compressed foo ~$ curl localhost:8080/response/small -H "Accept-Encoding: gzip" --compressed <NO RESPONSE> ~$ curl localhost:8080/response/small -H "Accept-Encoding: deflate" --compressed fo <MISSING 1 CHARACTER> ~$ curl localhost:8080/response/large -H "Accept-Encoding: none" --compressed foofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoofoo ~$ curl localhost:8080/response/large -H "Accept-Encoding: gzip" --compressed ^C <APP HANGS> ~$ curl localhost:8080/response/large -H "Accept-Encoding: deflate" --compressed ^C <APP HANGS>
The text was updated successfully, but these errors were encountered:
Thanks for report.
@fafhrd91 do you have a time to take a look?
Sorry, something went wrong.
Remove Content-Length header on compressed responses #450
1f3a6be
It was because enabling compression did not remove Content-Length header. Fixed by 1f3a6be
Content-Length
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.
asvetlov
No branches or pull requests
Calling
enable_compression
on a response does not work as expected at all. The response misses data or the whole handler hangs.The app below reproduces the problem:
Run the app and then execute the following:
The text was updated successfully, but these errors were encountered: