Update BINARY_SUPPORT to use Content-Encoding to identify if data is binary#2170
Open
monkut wants to merge 11 commits intoMiserlou:masterfrom
Open
Update BINARY_SUPPORT to use Content-Encoding to identify if data is binary#2170monkut wants to merge 11 commits intoMiserlou:masterfrom
monkut wants to merge 11 commits intoMiserlou:masterfrom
Conversation
When using _whitenoise_ for caching, which provides compression, binary types may include mimetypes, "text/", "application/json":
- response.mimetype.startswith("text/")
- response.mimetype == "application/json"
Assuming that Content-Encoding will be set (as whitenoise apparently does) this allows compression to be applied by the application for "text/" and "application/json".
About Content-Encoding:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
Use Content-Encoding to identify if data is binary
Include fallbacks for cases: - try binary, fail to text - try text, fail to binary
🔧 clean-up BINARY_SUPPORT handling
Quidge
added a commit
to tackle-io/Zappa
that referenced
this pull request
Apr 28, 2021
When using _whitenoise_ for caching, which provides compression, binary types
may include mimetypes, "text/", "application/json":
- response.mimetype.startswith("text/")
- response.mimetype == "application/json"
Assuming that Content-Encoding will be set (as whitenoise apparently does)
this allows compression to be applied by the application for "text/" and
"application/json".
About Content-Encoding:
developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
---
The above commit message and functional code change to zappa/handler.py was
written by GH user @monkut and a PR was provided with
Miserlou/Zappa#2170.
That PR was not merged in before the fork from Miserlou/zappa to Zappa/zappa.
This commit copies the code from that PR, adds a comment line referencing the
new migrated issue, and additionally adds tests to confirm behavior.
Quidge
added a commit
to tackle-io/Zappa
that referenced
this pull request
Apr 29, 2021
When using _whitenoise_ for caching, which provides compression, binary types
may include mimetypes, "text/", "application/json":
- response.mimetype.startswith("text/")
- response.mimetype == "application/json"
Assuming that Content-Encoding will be set (as whitenoise apparently does)
this allows compression to be applied by the application for "text/" and
"application/json".
About Content-Encoding:
developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
---
The above commit message and functional code change to zappa/handler.py was
written by GH user @monkut and a PR was provided with
Miserlou/Zappa#2170.
That PR was not merged in before the fork from Miserlou/zappa to Zappa/zappa.
This commit copies the code from that PR, adds a comment line referencing the
new migrated issue, and additionally adds tests to confirm behavior.
Co-authored-by: monkut <shane.cousins@gmail.com>
Quidge
added a commit
to tackle-io/Zappa
that referenced
this pull request
Jun 2, 2021
When using _whitenoise_ for caching, which provides compression, binary types
may include mimetypes, "text/", "application/json":
- response.mimetype.startswith("text/")
- response.mimetype == "application/json"
Assuming that Content-Encoding will be set (as whitenoise apparently does)
this allows compression to be applied by the application for "text/" and
"application/json".
About Content-Encoding:
developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
---
The above commit message and functional code change to zappa/handler.py was
written by GH user @monkut and a PR was provided with
Miserlou/Zappa#2170.
That PR was not merged in before the fork from Miserlou/zappa to Zappa/zappa.
This commit copies the code from that PR, adds a comment line referencing the
new migrated issue, and additionally adds tests to confirm behavior.
Co-authored-by: monkut <shane.cousins@gmail.com>
Quidge
added a commit
to tackle-io/Zappa
that referenced
this pull request
Nov 25, 2021
When using _whitenoise_ for caching, which provides compression, binary types
may include mimetypes, "text/", "application/json":
- response.mimetype.startswith("text/")
- response.mimetype == "application/json"
Assuming that Content-Encoding will be set (as whitenoise apparently does)
this allows compression to be applied by the application for "text/" and
"application/json".
About Content-Encoding:
developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
---
The above commit message and functional code change to zappa/handler.py was
written by GH user @monkut and a PR was provided with
Miserlou/Zappa#2170.
That PR was not merged in before the fork from Miserlou/zappa to Zappa/zappa.
This commit copies the code from that PR, adds a comment line referencing the
new migrated issue, and additionally adds tests to confirm behavior.
Co-authored-by: monkut <shane.cousins@gmail.com>
Quidge
added a commit
to tackle-io/Zappa
that referenced
this pull request
Nov 29, 2021
When using _whitenoise_ for caching, which provides compression, binary types
may include mimetypes, "text/", "application/json":
- response.mimetype.startswith("text/")
- response.mimetype == "application/json"
Assuming that Content-Encoding will be set (as whitenoise apparently does)
this allows compression to be applied by the application for "text/" and
"application/json".
About Content-Encoding:
developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
---
The above commit message and functional code change to zappa/handler.py was
written by GH user @monkut and a PR was provided with
Miserlou/Zappa#2170.
That PR was not merged in before the fork from Miserlou/zappa to Zappa/zappa.
This commit copies the code from that PR, adds a comment line referencing the
new migrated issue, and additionally adds tests to confirm behavior.
Co-authored-by: monkut <shane.cousins@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Alternative solution to #2080 intended to allow BINARY and text by making use of Content-Encoding header in the response.
When using whitenoise for caching, which provides compression, binary types may include mimetypes, "text/", "application/json":
Assuming that Content-Encoding will be set (as whitenoise apparently does) this allows compression to be applied to assets which have mimetypes "text/" and "application/json", while allowing for uncompressed "text/" and "application/json" still to be served.
About Content-Encoding:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
Not sure if this works for all use cases, but it currently appears to work for my workcase where whitenoise is performing compression of text/json files intended for caching, while still allowing text for html.
GitHub Issues
#2080