-
-
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
Add gzip support to FileSender #1426
Conversation
Current coverage is 98.83% (diff: 100%)@@ master #1426 diff @@
==========================================
Files 30 30
Lines 6931 6939 +8
Methods 0 0
Messages 0 0
Branches 1146 1149 +3
==========================================
+ Hits 6849 6858 +9
Misses 40 40
+ Partials 42 41 -1
|
Relying on filename with If you really need it -- create a route with desired behavior in your code. |
I think that it is a pretty common approach with servers. NGINX gzip compression works like this and also Apache has support for this. |
@asvetlov maybe this project needs some kind of repo with various recipes for pluggable things like root? Would address certain amount of PR and provide a ground for testing features to be considered for later integration. |
Hmm. Didn't know about NGINX option. I'm ok with the PR but new functionality should be test covered and documented. |
@Kentzo I don't follow what repo you are talking about. |
Cool. Will add some tests and docs soon. |
@asvetlov I have updated the PR with tests and docs. It is ready for review. |
It looks like the test failures are in code unrelated to my change. Both are related to url component encoding. Could it be due to the Yarl 0.8.1 release?
|
@balloob most likely yes. |
Rebased on the latest master |
All tests pass 💃 |
Thanks! |
@asvetlov would you be willing to accept a similar PR for Brotli format? |
@andrey-git I think payload writer should support |
btw I'd just add it everywhere. |
+1 |
Could you point me to where, except FileSender, support should be added? Turns out that |
It's not MIME type but Explained in #2518 |
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. |
What do these changes do?
When a FileSender object will send a file, it will now check if the request supports gzip and if a gzipped version of the file exists (
filepath + '.gz'
). If both checks pass, it will send the gzipped version to the client.This is something that we have been using in Home Assistant since we embraced aiohttp. I did not include tests/updated docs yet as I first wanted to know if it's something that would be accepted.
Are there changes in behavior for the user?
As an end user, you are now able to add gzipped versions of your files served through aiohttp.web.
Related issue number
Checklist
CONTRIBUTORS.txt
CHANGES.rst
#issue_number
format at the end of changelog message. Use Pull Request number if there are no issues for PR or PR covers the issue only partially.