Skip to content

Commit 2864fa8

Browse files
chore: broadly detect json family of content-type headers
1 parent e8a6836 commit 2864fa8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/finch/_legacy_response.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
297297
# split is required to handle cases where additional information is included
298298
# in the response, e.g. application/json; charset=utf-8
299299
content_type, *_ = response.headers.get("content-type", "*").split(";")
300-
if content_type != "application/json":
300+
if not content_type.endswith("json"):
301301
if is_basemodel(cast_to):
302302
try:
303303
data = response.json()

src/finch/_response.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
237237
# split is required to handle cases where additional information is included
238238
# in the response, e.g. application/json; charset=utf-8
239239
content_type, *_ = response.headers.get("content-type", "*").split(";")
240-
if content_type != "application/json":
240+
if not content_type.endswith("json"):
241241
if is_basemodel(cast_to):
242242
try:
243243
data = response.json()

0 commit comments

Comments
 (0)