From 8a895ff0d971ee44b37645e3fe78796c8bb6ebd9 Mon Sep 17 00:00:00 2001 From: david Date: Thu, 21 Jan 2010 00:23:56 +0000 Subject: [PATCH] Fix an error with http.request: If there was a parsing error or a network error, it was returning nil instead of a table as documented. --- nselib/http.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nselib/http.lua b/nselib/http.lua index e79d7e28b..75c60712e 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -1231,8 +1231,7 @@ request = function(host, port, data) end end - local response = {} - local result = {status=nil,["status-line"]=nil,header={},body=""} + local error_response = {status=nil,["status-line"]=nil,header={},body=""} local socket method = string.match(data, "^(%S+)") @@ -1240,13 +1239,13 @@ request = function(host, port, data) socket, partial = comm.tryssl(host, port, data, opts) if not socket then - return result + return error_response end repeat response, partial = next_response(socket, method, partial) if not response then - return nil, partial + return error_response end -- See RFC 2616, sections 8.2.3 and 10.1.1, for the 100 Continue status. -- Sometimes a server will tell us to "go ahead" with a POST body before