From dd471d09d536e6b82eecfa259edbc989c632f6fe Mon Sep 17 00:00:00 2001 From: ron Date: Thu, 1 Apr 2010 04:41:48 +0000 Subject: [PATCH] Fixed a bug in http.lua where http.post() wouldn't work if the arguments were passed in as a string instead of a table (the documentation says it should work in both places) --- nselib/http.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nselib/http.lua b/nselib/http.lua index 95cbccf73..9a4343e13 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -961,6 +961,7 @@ request = function(host, port, data, options) method = string.match(data, "^(%S+)") +--io.write(data) socket, partial = comm.tryssl(host, port, data, { timeout = options.timeout }) if not socket then @@ -1087,10 +1088,16 @@ post = function( host, port, path, options, ignored, postdata ) parts[#parts + 1] = url.escape(k) .. "=" .. url.escape(v) end postdata = table.concat(parts, "&") - mod_options.header["Content-Type"] = "application/x-www-form-urlencoded" + mod_options.content = postdata + else mod_options.content = postdata end + if(not(mod_options.header)) then + mod_options.header = {} + end + mod_options.header["Content-Type"] = "application/x-www-form-urlencoded" + table_augment(mod_options, options or {}) return generic_request(host, port, "POST", path, mod_options)