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] All responses are base64 encoded #633

Closed
jneves opened this issue Feb 20, 2021 · 1 comment
Closed

[Migrated] All responses are base64 encoded #633

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#1605 by joeldentici

It seems that Zappa always responds with a base64 encoded string for the response body and "isBase64Encoded" set to true.

The relevant file is the "handler.py" file provided/generated by Zappa.

On line 513, we have this if statement:

if not response.mimetype.startswith("text/") \
    or response.mimetype != "application/json":

The condition's negation is:

response.mimetype.startswith("text/") and response.mimetype == "application/json"

Clearly this is a contradiction, so the condition itself is a tautology. The true branch is taken and Zappa will always base64 encode responses.

It seems that the intention of the condition is to NOT base64 encode responses that are text (but to take a conservative approach to determine what is "text").

It seems that what we want is to NOT base64 encode when this condition is true:

response.mimetype.startswith('text/') or response.mimetype == 'application/json'

If this is the case, the condition starting on line 513 should instead be:

not response.mimetype.startswith('text/') and response.mimetype != 'application/json'

I noticed this while using Zappa 0.46.2

@monkut monkut added the duplicate This issue or pull request already exists label Jul 16, 2022
@monkut
Copy link
Collaborator

monkut commented Jul 16, 2022

duplicate
#908

closing

@monkut monkut closed this as completed Jul 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