Skip to content

Commit 6e090a3

Browse files
Thomas ChuConni2461
authored andcommitted
fix: remove formatting header keys for curl
1 parent 1a0bb83 commit 6e090a3

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

lua/plenary/curl.lua

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,7 @@ parse.headers = function(t)
9191
if not t then
9292
return
9393
end
94-
local upper = function(str)
95-
return string.gsub(" " .. str, "%W%l", string.upper):sub(2)
96-
end
97-
return util.kv_to_list(
98-
(function()
99-
local normilzed = {}
100-
for k, v in pairs(t) do
101-
normilzed[upper(k:gsub("_", "%-"))] = v
102-
end
103-
return normilzed
104-
end)(),
105-
"-H",
106-
": "
107-
)
94+
return util.kv_to_list(t, "-H", ": ")
10895
end
10996

11097
parse.data_body = function(t)

tests/plenary/curl_spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe("CURL Wrapper:", function()
145145
local res = curl.post("https://postman-echo.com/post", {
146146
body = vim.fn.json_encode(json),
147147
headers = {
148-
content_type = "application/json",
148+
["content-type"] = "application/json",
149149
},
150150
}).body
151151
eq(json, vim.fn.json_decode(res).json)
@@ -157,7 +157,7 @@ describe("CURL Wrapper:", function()
157157
local res = curl.post("https://postman-echo.com/post", {
158158
body = body,
159159
headers = {
160-
content_type = "application/json",
160+
["content-type"] = "application/json",
161161
},
162162
dry_run = true,
163163
})

0 commit comments

Comments
 (0)