File tree 1 file changed +17
-2
lines changed
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,19 @@ local function create_error_handler(opts)
54
54
end
55
55
end
56
56
57
+ local function parse_headers (headers )
58
+ local parsed = {}
59
+ for _ , header in ipairs (headers ) do
60
+ if header ~= " " then
61
+ local key , value = header :match (" ([^:]+):%s*(.*)" )
62
+ if key then
63
+ parsed [key ] = value or " "
64
+ end
65
+ end
66
+ end
67
+ return parsed
68
+ end
69
+
57
70
-- get_or_create_buf checks if there is already a buffer with the rest run results
58
71
-- and if the buffer does not exists, then create a new one
59
72
M .get_or_create_buf = function ()
@@ -103,6 +116,8 @@ local function create_callback(curl_cmd, opts)
103
116
return
104
117
end
105
118
local res_bufnr = M .get_or_create_buf ()
119
+ local header_lines = res .headers
120
+ res .headers = parse_headers (res .headers )
106
121
local content_type = res .headers [utils .key (res .headers ,' content-type' )]
107
122
if content_type then
108
123
content_type = content_type :match (" application/([-a-z]+)" ) or content_type :match (" text/(%l+)" )
@@ -154,9 +169,9 @@ local function create_callback(curl_cmd, opts)
154
169
vim .api .nvim_buf_set_lines (
155
170
res_bufnr ,
156
171
line_count + 1 ,
157
- line_count + 1 + # res . headers ,
172
+ line_count + 1 + # header_lines ,
158
173
false ,
159
- res . headers
174
+ header_lines
160
175
)
161
176
end
162
177
You can’t perform that action at this time.
0 commit comments