Skip to content

Commit

Permalink
fix: int serialization for multipart requests
Browse files Browse the repository at this point in the history
urllib3 handles serializing ints in post params (ref 1), while asyncio
explicitly does not (ref 2).

ref 1: <https://github.com/urllib3/urllib3/blob/9316764e90aea8d193cd8f03b0caccdf02af3ba0/src/urllib3/filepost.py#L75-L76>
ref 2: <aio-libs/aiohttp#920>
  • Loading branch information
roryschadler committed Aug 7, 2024
1 parent 0e4ff73 commit 29b4a60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class RESTClientObject:
# Ensures that dict objects are serialized
if isinstance(v, dict):
v = json.dumps(v)
elif isinstance(v, int):
v = str(v)
data.add_field(k, v)
args["data"] = data

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ async def request(
# Ensures that dict objects are serialized
if isinstance(v, dict):
v = json.dumps(v)
elif isinstance(v, int):
v = str(v)
data.add_field(k, v)
args["data"] = data

Expand Down

0 comments on commit 29b4a60

Please sign in to comment.