[Python][Client] Allow all content-types with text/ prefix (#19802)

* ODM-12108: allow all content-types with text/ prefix

* ODM-12108: Update deserialization tests

---------

Co-authored-by: Oleg Kunitsyn <you@example.com>
This commit is contained in:
Kunitsyn Oleg
2024-10-08 03:34:36 +02:00
committed by GitHub
parent 7d1e9997d0
commit 4ff8c3aaef
10 changed files with 18 additions and 12 deletions

View File

@@ -410,7 +410,7 @@ class ApiClient:
data = ""
else:
data = json.loads(response_text)
elif re.match(r'^text/plain\s*(;|$)', content_type, re.IGNORECASE):
elif re.match(r'^text\/[a-z.+-]+\s*(;|$)', content_type, re.IGNORECASE):
data = response_text
else:
raise ApiException(

View File

@@ -226,7 +226,7 @@ class RESTClientObject:
headers=headers,
preload_content=False
)
elif headers['Content-Type'] == 'text/plain' and isinstance(body, bool):
elif headers['Content-Type'].startswith('text/') and isinstance(body, bool):
request_body = "true" if body else "false"
r = self.pool_manager.request(
method,