pcurl: -d implies form-urlencoded content type (curl semantics)

This commit is contained in:
vex1023 committed 2026-10-01 10:52:53 +08:00
1 parent b48a3216bf
commit 99e03c9d14
1 file changed
+5
+5
View File
@@ -146,6 +146,11 @@ def main():
req_kw['data'] = body
elif body:
req_kw['data'] = body
# curl semantics: -d implies form-urlencoded content type
if not any(k.lower() == 'content-type' for k in (hdrs or {})):
hdrs = dict(hdrs or {})
hdrs['Content-Type'] = 'application/x-www-form-urlencoded'
req_kw['headers'] = hdrs
resp = client.request(method, url, **req_kw)
except Exception as e:
msg = str(e)