From 99e03c9d14d1d8da91a904ef2d7bc4045e653798 Mon Sep 17 00:00:00 2001 From: vex1023 Date: Thu, 1 Oct 2026 10:52:53 +0800 Subject: [PATCH] pcurl: -d implies form-urlencoded content type (curl semantics) --- src/primp_patch/curl.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/primp_patch/curl.py b/src/primp_patch/curl.py index cdae920..fa91789 100755 --- a/src/primp_patch/curl.py +++ b/src/primp_patch/curl.py @@ -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)