feat(client): support return response_cls to string (#614)

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
This commit is contained in:
Aaron Pham
2023-11-12 01:15:35 -05:00
committed by GitHub
parent fad4186dbc
commit bbd20aed89

View File

@@ -134,6 +134,9 @@ class APIResponse(t.Generic[Response]):
stream_cls = self._stream_cls or self._client._default_stream_cls
return stream_cls(response_cls=self._response_cls, response=self._raw_response, client=self._client)
if self._response_cls is str:
return self._raw_response.text
content_type, *_ = self._raw_response.headers.get('content-type', '').split(';')
if content_type != 'application/json':
# Since users specific different content_type, then we return the raw binary text without and deserialisation