diff --git a/src/babashka/curl.clj b/src/babashka/curl.clj index 0379881..b78b4df 100644 --- a/src/babashka/curl.clj +++ b/src/babashka/curl.clj @@ -74,13 +74,7 @@ (case method :head ["--head"] ["--request" (-> method name str/upper-case)])) - headers (:headers opts) - headers (loop [headers* (transient []) - kvs (seq headers)] - (if kvs - (let [[k v] (first kvs)] - (recur (reduce conj! headers* ["-H" (str k ": " v)]) (next kvs))) - (persistent! headers*))) + headers (into [] (mapcat (fn [[k v]] ["-H" (str (name k) ": " v)])) (:headers opts)) accept-header (accept-header opts) form-params (when-let [form-params (:form-params opts)] (loop [params* (transient []) diff --git a/test/babashka/curl_test.clj b/test/babashka/curl_test.clj index ccb3728..69c24b4 100644 --- a/test/babashka/curl_test.clj +++ b/test/babashka/curl_test.clj @@ -255,3 +255,11 @@ (-> (curl/get "https://api.stackexchange.com/2.2/sites" {:compressed false}) :body (json/parse-string true) :items)))) + +(deftest header-with-keyword-key-test + (is (= 200 + (-> (curl/get "https://httpstat.us/200" + {:headers {:accept "application/json"}}) + :body + (json/parse-string true) + :code))))