From 6e090a3a7af3439077c8583fd487a49169380b27 Mon Sep 17 00:00:00 2001 From: Thomas Chu Date: Mon, 21 Oct 2024 23:04:12 -0400 Subject: [PATCH] fix: remove formatting header keys for curl --- lua/plenary/curl.lua | 15 +-------------- tests/plenary/curl_spec.lua | 4 ++-- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/lua/plenary/curl.lua b/lua/plenary/curl.lua index 20e8cc270..4308d1f4e 100644 --- a/lua/plenary/curl.lua +++ b/lua/plenary/curl.lua @@ -91,20 +91,7 @@ parse.headers = function(t) if not t then return end - local upper = function(str) - return string.gsub(" " .. str, "%W%l", string.upper):sub(2) - end - return util.kv_to_list( - (function() - local normilzed = {} - for k, v in pairs(t) do - normilzed[upper(k:gsub("_", "%-"))] = v - end - return normilzed - end)(), - "-H", - ": " - ) + return util.kv_to_list(t, "-H", ": ") end parse.data_body = function(t) diff --git a/tests/plenary/curl_spec.lua b/tests/plenary/curl_spec.lua index c268492fe..9e95e2f39 100644 --- a/tests/plenary/curl_spec.lua +++ b/tests/plenary/curl_spec.lua @@ -145,7 +145,7 @@ describe("CURL Wrapper:", function() local res = curl.post("https://postman-echo.com/post", { body = vim.fn.json_encode(json), headers = { - content_type = "application/json", + ["content-type"] = "application/json", }, }).body eq(json, vim.fn.json_decode(res).json) @@ -157,7 +157,7 @@ describe("CURL Wrapper:", function() local res = curl.post("https://postman-echo.com/post", { body = body, headers = { - content_type = "application/json", + ["content-type"] = "application/json", }, dry_run = true, })