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 binary_support handling #2029

Merged
merged 1 commit into from
Feb 21, 2020
Merged

Conversation

jait
Copy link
Contributor

@jait jait commented Feb 20, 2020

Description

The logic of handling response data when binary_support is True, was faulty. It base64-encoded every response, regardless of the content-type, which caused the user/browser to receive base64-encoded bodies if deployed with an API Gateway. ALB apparently supports base64-encoded responses and manages to decode them.

GitHub Issues

Relevant tickets:

@coveralls
Copy link

coveralls commented Feb 20, 2020

Coverage Status

Coverage decreased (-0.04%) to 72.903% when pulling 222ea52 on jait:bugfix/fix-binary-support into f4e846f on Miserlou:master.

@jneves jneves merged commit bf015b0 into Miserlou:master Feb 21, 2020
@jneves
Copy link
Collaborator

jneves commented Feb 21, 2020

Thanks!

@martinv13
Copy link

There was indeed a bug in the logic with the condition being always true as discussed in #1605 .

However this PR broke my setup where response is compressed at application level (with flask_compress). The response is forced through response.get_data(as_text=True), which fails with gzipped payload.

I think a lighter change (just changing the "or" for a "and" in the following condition: not response.mimetype.startswith("text/") or response.mimetype != "application/json") would have fixed the problem without breaking the use case where the response is gzipped text.

I can send a new PR if you agree.
Thanks in advance!

@mzaglia
Copy link

mzaglia commented Apr 17, 2020

I'm having the same problem as @martinv13 after compressing my response.

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.

5 participants