@@ -65,6 +65,7 @@ local function get_body(bufnr, start_line, stop_line, has_json)
65
65
-- but start_line and stop_line are one-based and inclusive
66
66
-- magically, this fits :-) start_line is the CRLF between header and body
67
67
-- which should not be included in the body, stop_line is the last line of the body
68
+ local vars = utils .read_variables ()
68
69
for i , line in ipairs (lines ) do
69
70
log .fmt_debug (" Line %s" , line )
70
71
-- stop if a script opening tag is found
@@ -75,7 +76,7 @@ local function get_body(bufnr, start_line, stop_line, has_json)
75
76
end
76
77
-- Ignore commented lines with and without indent
77
78
if not utils .contains_comments (line ) then
78
- body = body .. utils .replace_vars (line )
79
+ body = body .. utils .replace_vars (line , vars )
79
80
end
80
81
end
81
82
@@ -143,7 +144,8 @@ local function get_headers(bufnr, start_line, end_line)
143
144
local header_name , header_value = line_content :match (" ^(.-): ?(.*)$" )
144
145
145
146
if not utils .contains_comments (header_name ) then
146
- headers [header_name :lower ()] = utils .replace_vars (header_value )
147
+ local vars = utils .read_variables ()
148
+ headers [header_name :lower ()] = utils .replace_vars (header_value , vars )
147
149
end
148
150
:: continue::
149
151
end
@@ -232,10 +234,11 @@ local function parse_url(stmt)
232
234
table.remove (parsed , 1 )
233
235
local target_url = table.concat (parsed , " " )
234
236
237
+ local vars = utils .load
235
238
return {
236
239
method = http_method ,
237
240
-- Encode URL
238
- url = utils .encode_url (utils .replace_vars (target_url )),
241
+ url = utils .encode_url (utils .replace_vars (target_url , vars )),
239
242
http_version = http_version ,
240
243
}
241
244
end
@@ -274,7 +277,7 @@ M.get_current_request = function()
274
277
string.find (headers [" content-type" ] or " " , " application/[^ ]-json" )
275
278
)
276
279
log .fmt_debug (" Identified body as:\n %s" , body )
277
- script_str = get_response_script (bufnr , script_line , end_line )
280
+ script_str = get_response_script (bufnr , body_start , end_line )
278
281
279
282
if config .get (" jump_to_request" ) then
280
283
utils .move_cursor (bufnr , start_line )
0 commit comments