mirror of
https://github.com/nmap/nmap.git
synced 2025-12-10 09:49:05 +00:00
Added 'rawheader' when parsing http requests. It saves the header fields, in order, preserving the case. Change http-headers.nse to read this instead of the processed headers.
This commit is contained in:
@@ -948,7 +948,7 @@ end
|
|||||||
-- @return A table with the values received from the server
|
-- @return A table with the values received from the server
|
||||||
function parseResult( response )
|
function parseResult( response )
|
||||||
if type(response) ~= "string" then return response end
|
if type(response) ~= "string" then return response end
|
||||||
local result = {status=nil,["status-line"]=nil,header={},body=""}
|
local result = {status=nil,["status-line"]=nil,header={},rawheader={},body=""}
|
||||||
|
|
||||||
-- try and separate the head from the body
|
-- try and separate the head from the body
|
||||||
local header, body
|
local header, body
|
||||||
@@ -974,6 +974,8 @@ function parseResult( response )
|
|||||||
else
|
else
|
||||||
match, _, key, value = string.find( line, "(.+): (.*)" )
|
match, _, key, value = string.find( line, "(.+): (.*)" )
|
||||||
if match and key and value then
|
if match and key and value then
|
||||||
|
-- Keep the raw header too, in case a script wants to access it
|
||||||
|
table.insert(result['rawheader'], line)
|
||||||
key = key:lower()
|
key = key:lower()
|
||||||
if result.header[key] then
|
if result.header[key] then
|
||||||
result.header[key] = result.header[key] .. ',' .. value
|
result.header[key] = result.header[key] .. ',' .. value
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ action = function(host, port)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local response = " \n"
|
local response = " \n"
|
||||||
for i, v in pairs(result.header) do
|
for _, header in pairs(result.rawheader) do
|
||||||
response = response .. string.format(" %s: %s\n", i, v)
|
response = response .. header .. "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|||||||
Reference in New Issue
Block a user