Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat "application/problem+json" as non binary by default #503

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Changelog

Thanks to Zoe Guillen for the report in `PR #496 <https://github.com/adamchainz/apig-wsgi/pull/496>`__.

* Treat the content-type header "application/problem+json" as non binary by default.

Thanks to Ido Savion in `PR #503 <https://github.com/adamchainz/apig-wsgi/pull/503>`__.

* Support Python 3.13.

* Drop Python 3.8 support.
Expand Down
7 changes: 6 additions & 1 deletion src/apig_wsgi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)

Expand Down Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion tests/test_apig_wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)


Expand Down