diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fc35352..ea68e0c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,10 @@ Changelog Thanks to Zoe Guillen for the report in `PR #496 `__. +* Treat the content-type header "application/problem+json" as non binary by default. + + Thanks to Ido Savion in `PR #503 `__. + * Support Python 3.13. * Drop Python 3.8 support. diff --git a/src/apig_wsgi/__init__.py b/src/apig_wsgi/__init__.py index bb8fbdc..e786628 100644 --- a/src/apig_wsgi/__init__.py +++ b/src/apig_wsgi/__init__.py @@ -21,6 +21,11 @@ DEFAULT_NON_BINARY_CONTENT_TYPE_PREFIXES: tuple[str, ...] = ( "text/", "application/json", + # application/problem+json - a draft standard for JSON error responses + # https://datatracker.ietf.org/doc/html/draft-ietf-appsawg-http-problem-00#section-3 + "application/problem+json", + # application/vnd.api+json - JSON:API specification + # https://jsonapi.org/ "application/vnd.api+json", ) @@ -50,7 +55,7 @@ def make_lambda_handler( Whether to support returning APIG-compatible binary responses non_binary_content_type_prefixes : tuple of str Tuple of content type prefixes which should be considered "Non-Binary" when - `binray_support` is True. This prevents apig_wsgi from unexpectedly encoding + `binary_support` is True. This prevents apig_wsgi from unexpectedly encoding non-binary responses as binary. """ if non_binary_content_type_prefixes is None: diff --git a/tests/test_apig_wsgi.py b/tests/test_apig_wsgi.py index c906007..a2ec224 100644 --- a/tests/test_apig_wsgi.py +++ b/tests/test_apig_wsgi.py @@ -54,7 +54,13 @@ def simple_app() -> Generator[App]: parametrize_default_text_content_type = pytest.mark.parametrize( "text_content_type", - ["text/plain", "text/html", "application/json", "application/vnd.api+json"], + [ + "text/plain", + "text/html", + "application/json", + "application/problem+json", + "application/vnd.api+json", + ], )