Skip to content

Commit

Permalink
Treat "application/problem+json" as non binary by default (#503)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: Ido Savion <[email protected]>
Co-authored-by: Ido Savion <[email protected]>
Co-authored-by: Adam Johnson <[email protected]>
  • Loading branch information
3 people authored Oct 7, 2024
1 parent f949d39 commit 88fecf8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
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

0 comments on commit 88fecf8

Please sign in to comment.