diff --git a/zappa/handler.py b/zappa/handler.py index 88976b4d7..920ad928f 100644 --- a/zappa/handler.py +++ b/zappa/handler.py @@ -20,11 +20,11 @@ # so handle both scenarios. try: from zappa.middleware import ZappaWSGIMiddleware - from zappa.utilities import merge_headers, parse_s3_url + from zappa.utilities import merge_headers, parse_s3_url, DEFAULT_TEXT_MIMETYPES from zappa.wsgi import common_log, create_wsgi_request except ImportError: # pragma: no cover from .middleware import ZappaWSGIMiddleware - from .utilities import merge_headers, parse_s3_url + from .utilities import merge_headers, parse_s3_url, DEFAULT_TEXT_MIMETYPES from .wsgi import common_log, create_wsgi_request @@ -286,7 +286,7 @@ def _process_response_body(response: Response, settings: ModuleType) -> Tuple[st """ encode_body_as_base64 = False if settings.BINARY_SUPPORT: - handle_as_text_mimetypes = ("text/", "application/json") + handle_as_text_mimetypes = DEFAULT_TEXT_MIMETYPES additional_text_mimetypes = getattr(settings, "ADDITIONAL_TEXT_MIMETYPES", None) if additional_text_mimetypes: handle_as_text_mimetypes += tuple(additional_text_mimetypes) diff --git a/zappa/utilities.py b/zappa/utilities.py index 72ad9f0f7..87a7fa3b3 100644 --- a/zappa/utilities.py +++ b/zappa/utilities.py @@ -20,6 +20,19 @@ # Settings / Packaging ## +# mimetypes starting with entries defined here are considered as TEXT when BINARTY_SUPPORT is True. +# - Additional TEXT mimetypes may be defined with the 'ADDITIONAL_TEXT_MIMETYPES' setting. +DEFAULT_TEXT_MIMETYPES = ( + "text/", + "application/json", # RFC 4627 + "application/javascript", # RFC 4329 + "application/ecmascript", # RFC 4329 + "application/xml", # RFC 3023 + "application/xml-external-parsed-entity", # RFC 3023 + "application/xml-dtd", # RFC 3023 + "image/svg+xml", # RFC 3023 +) + def copytree(src, dst, metadata=True, symlinks=False, ignore=None): """