Allow to pass a str to the Python aiohttp client (#18985)

* see #18972

Add support for `str`

* update python samples

---------

Co-authored-by: David Riccitelli <david@wordlift.io>
This commit is contained in:
William Cheng 2024-06-23 17:19:26 +08:00 committed by GitHub
parent 4e89436177
commit 1064cb6a68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -177,10 +177,10 @@ class RESTClientObject:
data.add_field(k, v)
args["data"] = data
# Pass a `bytes` parameter directly in the body to support
# Pass a `bytes` or `str` parameter directly in the body to support
# other content types than Json when `body` argument is provided
# in serialized form
elif isinstance(body, bytes):
elif isinstance(body, str) or isinstance(body, bytes):
args["data"] = body
else:
# Cannot generate the request from given parameters

View File

@ -187,10 +187,10 @@ class RESTClientObject:
data.add_field(k, v)
args["data"] = data
# Pass a `bytes` parameter directly in the body to support
# Pass a `bytes` or `str` parameter directly in the body to support
# other content types than Json when `body` argument is provided
# in serialized form
elif isinstance(body, bytes):
elif isinstance(body, str) or isinstance(body, bytes):
args["data"] = body
else:
# Cannot generate the request from given parameters