Skip to content
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

fix Content-Type for gzip in StaticFileHandler #1468

Merged
merged 2 commits into from Jul 31, 2015
Merged

fix Content-Type for gzip in StaticFileHandler #1468

merged 2 commits into from Jul 31, 2015

Conversation

aebrahim
Copy link
Contributor

Python mimetypes module only recognizes gzip as the encoding. This will
detect a gzip encoding from mimetypes and make sure the Content-Type
ends up as application/gzip

This replaces #1465.

@bdarnell
Copy link
Member

This looks good, but can you add a test for it? You can add some small files with .gz or .bz2 extensions in tornado/test/static and test for them in web_test.py. You'll also need to add the new data files to MANIFEST.in and setup.py.

@aebrahim
Copy link
Contributor Author

OK, I'll create a new PR with both the test and the fixes.

@aebrahim aebrahim closed this Jul 30, 2015
@bdarnell
Copy link
Member

You don't have to close this PR; you can just push a new commit to the branch. It's usually better to re-use an existing PR to keep all the discussion about a change in one place.

@aebrahim
Copy link
Contributor Author

Oh, OK. Reopening and pushing new changes.

@aebrahim aebrahim reopened this Jul 30, 2015
@bdarnell
Copy link
Member

Some of the test failures aren't your fault; rebase or merge to get fixes for the twisted/asyncio stuff. You also need to replace a set literal in the test for python 2.6 compatibility.

The python mimetypes module used by StaticFileHandler will recognize
compression (gzip, bz2, etc.) as the file encoding, and will give the
mime type for the uncompressed file. This commit will fix this
behavior, so a gzip file will end up as application/gzip.
Additionally, unknown file types (or known file types compressed with
anything other than gzip) are served as application/octet-stream.
@aebrahim
Copy link
Contributor Author

OK, rebased and fixed.

bdarnell added a commit that referenced this pull request Jul 31, 2015
fix Content-Type for gzip in StaticFileHandler
@bdarnell bdarnell merged commit d370183 into tornadoweb:master Jul 31, 2015
@aebrahim aebrahim deleted the gzip_header branch August 5, 2015 07:02
zakandrewking added a commit to SBRG/bigg_models that referenced this pull request Aug 5, 2015
Checked encoding for compressed files, and serves the correct content
type. This is based on the pull request by @aebrahim here:
tornadoweb/tornado#1468
zakandrewking added a commit to SBRG/bigg_models that referenced this pull request Aug 5, 2015
Checked encoding for compressed files, and serves the correct content
type. This is based on the pull request by @aebrahim here:
tornadoweb/tornado#1468
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants