Skip to content

Commit

Permalink
feat(inspect): show auth headers on inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
gorillamoe committed Jan 13, 2025
1 parent eb0804e commit 2988cbf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lua/kulala/parser/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ end
---@field url_raw string -- The raw URL as it appears in the document
---@field url string -- The URL with variables and dynamic variables replaced
---@field headers table -- The headers with variables and dynamic variables replaced
---@field headers_display table -- The headers with variables and dynamic variables replaced and sanitized
---@field headers_raw table -- The headers as they appear in the document
---@field body_raw string|nil -- The raw body as it appears in the document
---@field body_computed string|nil -- The computed body as sent by curl; with variables and dynamic variables replaced
Expand All @@ -536,6 +537,7 @@ function M.get_basic_request_data(start_request_linenr)
url = "",
url_raw = "",
headers = {},
headers_display = {},
headers_raw = {},
body = nil,
body_raw = nil,
Expand Down Expand Up @@ -631,6 +633,8 @@ M.parse = function(start_request_linenr)
res.url, res.headers, res.body, res.body_display =
replace_variables_in_url_headers_body(res, document_variables, env, has_pre_request_scripts)

res.headers_display = vim.deepcopy(res.headers)

-- Merge headers from the $shared environment if it does not exist in the request
-- this ensures that you can always override the headers in the request
if DB.find_unique("http_client_env_shared") then
Expand Down
2 changes: 1 addition & 1 deletion lua/kulala/parser/inspect.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ M.get_contents = function()
return contents
end
table.insert(contents, req.method .. " " .. req.url .. (req.http_version and " HTTP/" .. req.http_version or ""))
for header_key, header_value in pairs(req.headers) do
for header_key, header_value in pairs(req.headers_display) do
table.insert(contents, header_key .. ": " .. header_value)
end
-- Use the body_display, because it's meant to be human-readable
Expand Down

0 comments on commit 2988cbf

Please sign in to comment.