Skip to content

enable_compression doesn't work with FileResponse in sendfile mode #2942

Closed
@savv

Description

Long story short

response.enable_compression doesn't work on Heroku.

Expected behaviour

enable_compression on a response should work on Heroku.

Actual behaviour

While this worked locally just fine, Heroku didn't like it when I enabled compression on a FileResponse:
Apr 17 11:58:19 my-app-staging heroku/router: http_error="Bad chunk" at=error code=H17 desc="Poorly formatted HTTP response" method=GET path="/" host=my-app-staging.herokuapp.com request_id=0bc47133-af19-4999-bc0f-179054b7388a fwd="xx.xx.xx.xx" dyno=web.1 connect=0ms service=19ms status=503 bytes= protocol=https
Apr 17 11:58:19 my-app-staging heroku/router: http_error="Bad chunk" at=error code=H17 desc="Poorly formatted HTTP response" method=GET path="/" host=my-app-staging.herokuapp.com request_id=9c1b4583-61d5-4867-bf1a-75de194cf71f fwd="xx.xx.xx.xx" dyno=web.1 connect=0ms service=5ms status=503 bytes= protocol=https
Apr 17 11:58:23 my-app-staging heroku/router: http_error="Bad chunk" at=error code=H17 desc="Poorly formatted HTTP response" method=GET path="/" host=my-app-staging.herokuapp.com request_id=a2f80aee-0ba0-4117-9139-123a79fd2f1c fwd="xx.xx.xx.xx" dyno=web.1 connect=0ms service=3ms status=503 bytes= protocol=https

Steps to reproduce

        resp = web.FileResponse('./dist/index.html', headers={'Cache-Control': 'no-cache'})
        resp.enable_compression()
        return resp

Your environment

aiohttp==2.3.6
Using aiohttp directly on Heroku (no gunicorn/etc).

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions