Skip to content

Commit

Permalink
proper encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Korovin committed Apr 4, 2022
1 parent d7b09e5 commit 4168a99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions yappa/handlers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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,
}

0 comments on commit 4168a99

Please # to comment.