Skip to content

Fix handling of gzip-encoded text response#1007

Closed
suriya wants to merge 1 commit intozappa:masterfrom
suriya:fix-gzip-encoded-response-1
Closed

Fix handling of gzip-encoded text response#1007
suriya wants to merge 1 commit intozappa:masterfrom
suriya:fix-gzip-encoded-response-1

Conversation

@suriya
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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.

3 participants