fix: omit Content-Type header when request body is empty (#40)

This commit is contained in:
Wang ChengMeng 2026-06-06 11:40:36 +00:00
parent 817f1a0816
commit 356edf427a

View file

@ -537,6 +537,9 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
else:
kwargs["json"] = json_data if is_given(json_data) else None
kwargs["files"] = files
# Don't send Content-Type when there's no body content
if not is_given(json_data) and not files:
headers.pop("Content-Type", None)
else:
headers.pop("Content-Type", None)
kwargs.pop("data", None)