Nmap Development mailing list archives
Re: [NSE] Return values inconsistent with documentation in http.lua
From: Peter O <perdo.olma () gmail com>
Date: Mon, 9 Jul 2012 12:19:43 +0200
On Tue, Jun 19, 2012 at 4:22 PM, David Fifield <david () bamsoftware com> wrote:
On Tue, Jun 19, 2012 at 03:20:46PM +0200, Peter O wrote:Hi all, there's an issue with return values of: get, head, post, put (basically every function that uses generic_request) functions from http.lua library. Comments above each of those functions suggest that nil is going to be returned in case of an error, but they can actually return either nil or error_response = {status=nil,["status-line"]=nil,header={},body=""}. Should we change those functions to always return a table? This approach is suggested by a comment starting in line 1046: "The format of the return value is a table with the following structure: {status = 200, status-line = "HTTP/1.1 200 OK", header = {}, rawheader = {}, body ="<html>...</html>"} [...] http status code of the request in case of an error status is nil." and that's also how it was done when the library came out in r6778.I think that the returns should always be a table in http.
In r29163, I've modified the library so that the returns are always a table. So now, in order to check if a request was successful, you need to examine response.status - if it's nil, then an error must have occurred and response['status-line'] has an explanation of what has gone wrong. - Peter _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Re: [NSE] Return values inconsistent with documentation in http.lua Peter O (Jul 09)