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 #1007

Closed
wants to merge 1 commit into from

Conversation

suriya
Copy link
Contributor

@suriya suriya commented Jul 17, 2021

Description

When Zappa receives a compressed text/plain response from the
application, it tries to process it as a text response. Instead, Zappa
should treat the response as if it were a binary one and base-64 encode
the response body.

Github Issues

See issue #2080 binary_support logic in handler.py (0.51.0) broke compressed text response
Miserlou/Zappa#2080

When Zappa receives a compressed text/plain response from the
application, it tries to process it as a text response. Instead, Zappa
should treat the response as if it were a binary one and base-64 encode
the response body.

See issue #2080 binary_support logic in handler.py (0.51.0) broke compressed text response
Miserlou/Zappa#2080
@john-parton
Copy link

john-parton commented Aug 19, 2021

Just need to look at the 'Content-Encoding' header on the werkzeug response. If it's present, then just base64 encode the response as normal.

This logic here:

                        if (
                            settings.BINARY_SUPPORT
                            and not response.mimetype.startswith("text/")
                            and response.mimetype != "application/json"
                        ):

Replace it with this

                        if (
                            response.headers.get("Content-Encoding") or
                            (settings.BINARY_SUPPORT
                            and not response.mimetype.startswith("text/")
                            and response.mimetype != "application/json")
                        ):

Edit

Sorry if this wasn't clear. Your PR looks like it should work. I was just suggesting that it could be restructured so there isn't duplicated code blocks.

@monkut
Copy link
Collaborator

monkut commented Aug 12, 2022

Issue supported in:
#1155

closing.

@monkut monkut closed this Aug 12, 2022
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

3 participants