diff --git a/nselib/http.lua b/nselib/http.lua index 76bc39eaf..920d4cc40 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -948,7 +948,7 @@ end -- @return A table with the values received from the server function parseResult( response ) 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 local header, body @@ -974,6 +974,8 @@ function parseResult( response ) else match, _, key, value = string.find( line, "(.+): (.*)" ) 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() if result.header[key] then result.header[key] = result.header[key] .. ',' .. value diff --git a/scripts/http-headers.nse b/scripts/http-headers.nse index 296f65381..de6ea9167 100644 --- a/scripts/http-headers.nse +++ b/scripts/http-headers.nse @@ -64,8 +64,8 @@ action = function(host, port) end local response = " \n" - for i, v in pairs(result.header) do - response = response .. string.format(" %s: %s\n", i, v) + for _, header in pairs(result.rawheader) do + response = response .. header .. "\n" end return response