diff --git a/zappa/handler.py b/zappa/handler.py index 78a31cfda..e86865c32 100644 --- a/zappa/handler.py +++ b/zappa/handler.py @@ -549,11 +549,13 @@ def handler(self, event, context): zappa_returndict.setdefault('statusDescription', response.status) if response.data: - if settings.BINARY_SUPPORT and \ - not response.mimetype.startswith("text/") \ + if settings.BINARY_SUPPORT: + if not response.mimetype.startswith("text/") \ and response.mimetype != "application/json": - zappa_returndict['body'] = base64.b64encode(response.data).decode('utf-8') - zappa_returndict["isBase64Encoded"] = True + zappa_returndict['body'] = base64.b64encode(response.data).decode('utf-8') + zappa_returndict["isBase64Encoded"] = True + else: + zappa_returndict['body'] = response.data else: zappa_returndict['body'] = response.get_data(as_text=True)