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

[Migrated] binary_support logic in handler.py (0.51.0) broke compressed text response #838

Closed
jneves opened this issue Feb 20, 2021 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@jneves
Copy link
Contributor

jneves commented Feb 20, 2021

Originally from: Miserlou/Zappa#2080 by martinv13

Context

The binary_support setting used to allow compressing response at application level (for instance using flask_compress) in version 0.50.0. As of 0.51.0 it no longer works.

Expected Behavior

Compressed response using flask_compress should be possible.

Actual Behavior

In handler.py, response is forced through response.get_data(as_text=True), which fails for compressed payload, thus throwing an error. This is due to the modifications in #2029 which fixed a bug (previously all responses where base64 encoded), but introduced this one.

Possible Fix

A possibility would be to partially revert to the previous version and just change in handler.py the "or" for a "and" in the following condition: not response.mimetype.startswith("text/") or response.mimetype != "application/json"). I can propose a simple PR for this.

Steps to Reproduce

Configure Flask with flask_compress; any text or json response will fail with the following error: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

Your Environment

  • Zappa version used: 0.51.0
  • Operating System and Python version: Python 3.7 on Lambda
  • Your zappa_settings.json: relevant option: binary_support: true
@monkut monkut added the duplicate This issue or pull request already exists label Aug 16, 2022
@monkut
Copy link
Collaborator

monkut commented Aug 16, 2022

marking as a duplicate of the following and closing.
#908

@monkut monkut closed this as completed Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants