diff --git a/setup.py b/setup.py index ac4afda..2eda757 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='yappa', - version='0.4.20', + version='0.4.21', url='https://github.com/turokg/yappa', description='Easy serverless deploy of python web applications', long_description_content_type="text/markdown", diff --git a/yappa/handlers/common.py b/yappa/handlers/common.py index 4b621fe..f455ab2 100644 --- a/yappa/handlers/common.py +++ b/yappa/handlers/common.py @@ -64,6 +64,7 @@ def get_encoding(response): for re_ in ENCODED_CONTENT_TYPES: if re_.match(content_type): return True + return False def patch_response(response): @@ -75,9 +76,10 @@ def patch_response(response): 'headers': {} } """ + is_encoded = get_encoding(response) return { 'statusCode': response.status_code, 'headers': dict(response.headers), - 'body': response.content.decode(), - 'isBase64Encoded': get_encoding(response), + 'body': response.content if is_encoded else response.content.encode(), + 'isBase64Encoded': is_encoded, }