File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 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)
5454 end
5555end
5656
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+
5770-- get_or_create_buf checks if there is already a buffer with the rest run results
5871-- and if the buffer does not exists, then create a new one
5972M .get_or_create_buf = function ()
@@ -103,6 +116,8 @@ local function create_callback(curl_cmd, opts)
103116 return
104117 end
105118 local res_bufnr = M .get_or_create_buf ()
119+ local header_lines = res .headers
120+ res .headers = parse_headers (res .headers )
106121 local content_type = res .headers [utils .key (res .headers ,' content-type' )]
107122 if content_type then
108123 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)
154169 vim .api .nvim_buf_set_lines (
155170 res_bufnr ,
156171 line_count + 1 ,
157- line_count + 1 + # res . headers ,
172+ line_count + 1 + # header_lines ,
158173 false ,
159- res . headers
174+ header_lines
160175 )
161176 end
162177
You can’t perform that action at this time.
0 commit comments