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 handling of gzip-encoded text response #2141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion zappa/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,12 @@ def handler(self, event, context):
zappa_returndict.setdefault('statusDescription', response.status)

if response.data:
if settings.BINARY_SUPPORT and \
if settings.BINARY_SUPPORT and response.headers.get("Content-Encoding"):
# We could have a text response that's gzip
# encoded. Therefore, we base-64 encode it.
zappa_returndict['body'] = base64.b64encode(response.data).decode('utf-8')
zappa_returndict["isBase64Encoded"] = True
elif settings.BINARY_SUPPORT and \
not response.mimetype.startswith("text/") \
and response.mimetype != "application/json":
zappa_returndict['body'] = base64.b64encode(response.data).decode('utf-8')
Expand Down