mirror of
https://github.com/nmap/nmap.git
synced 2026-01-20 13:19:01 +00:00
Adds HTTP protocol version as a new member of the HTTP response table. Closes 934
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
# Nmap Changelog ($Id$); -*-text-*-
|
||||
|
||||
o [NSE][GH#934] The HTTP response object has a new member, version, which
|
||||
contains the HTTP protocol version string returned by the server, e.g. "1.1".
|
||||
[nnposter]
|
||||
|
||||
o [NSE] openwebnet-discovery retrieves device identifying information and
|
||||
number of connected devices running on openwebnet protocol. [Rewanth Cool]
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
-- These functions return a table of values, including:
|
||||
-- * <code>status-line</code> - A string representing the status, such as "HTTP/1.1 200 OK". In case of an error, a description will be provided in this line.
|
||||
-- * <code>status</code> - The HTTP status value; for example, "200". If an error occurs during a request, then this value is going to be nil.
|
||||
-- * <code>version</code> - HTTP protocol version string, as stated in the status line. Example: "1.1"
|
||||
-- * <code>header</code> - An associative array representing the header. Keys are all lowercase, and standard headers, such as 'date', 'content-length', etc. will typically be present.
|
||||
-- * <code>rawheader</code> - A numbered array of the headers, exactly as the server sent them. While header['content-type'] might be 'text/html', rawheader[3] might be 'Content-type: text/html'.
|
||||
-- * <code>cookies</code> - A numbered array of the cookies the server sent. Each cookie is a table with the following keys: <code>name</code>, <code>value</code>, <code>path</code>, <code>domain</code>, and <code>expires</code>.
|
||||
@@ -54,6 +55,7 @@
|
||||
-- The response to each function is typically a table with the following keys:
|
||||
-- * <code>status-line</code>: The HTTP status line; for example, "HTTP/1.1 200 OK" (note: this is followed by a newline). In case of an error, a description will be provided in this line.
|
||||
-- * <code>status</code>: The HTTP status value; for example, "200". If an error occurs during a request, then this value is going to be nil.
|
||||
-- * <code>version</code>: HTTP protocol version string, as stated in the status line. Example: "1.1"
|
||||
-- * <code>header</code>: A table of header values, where the keys are lowercase and the values are exactly what the server sent
|
||||
-- * <code>rawheader</code>: A list of header values as "name: value" strings, in the exact format and order that the server sent them
|
||||
-- * <code>cookies</code>: A list of cookies that the server is sending. Each cookie is a table containing the keys <code>name</code>, <code>value</code>, and <code>path</code>. This table can be sent to the server in subsequent responses in the <code>options</code> table to any function (see below).
|
||||
@@ -567,7 +569,6 @@ end
|
||||
-- and the status code of the response.
|
||||
local function recv_body(s, response, method, partial)
|
||||
local connection_close, connection_keepalive
|
||||
local version_major, version_minor
|
||||
local transfer_encoding
|
||||
local content_length
|
||||
local err
|
||||
@@ -594,9 +595,6 @@ local function recv_body(s, response, method, partial)
|
||||
end
|
||||
end
|
||||
|
||||
-- The HTTP version may also affect our decisions.
|
||||
version_major, version_minor = string.match(response["status-line"], "^HTTP/(%d+)%.(%d+)")
|
||||
|
||||
-- See RFC 2616, section 4.4 "Message Length".
|
||||
|
||||
-- 1. Any response message which "MUST NOT" include a message-body (such as
|
||||
@@ -610,7 +608,7 @@ local function recv_body(s, response, method, partial)
|
||||
if string.upper(method) == "HEAD"
|
||||
or (response.status >= 100 and response.status <= 199)
|
||||
or response.status == 204 or response.status == 304 then
|
||||
if connection_close or (version_major == "1" and version_minor == "0" and not connection_keepalive) then
|
||||
if connection_close or (response.version == "1.0" and not connection_keepalive) then
|
||||
return recv_all(s, partial)
|
||||
else
|
||||
return "", partial
|
||||
@@ -657,7 +655,7 @@ local function recv_body(s, response, method, partial)
|
||||
return recv_all(s, partial)
|
||||
end
|
||||
|
||||
-- Sets response["status-line"] and response.status.
|
||||
-- Sets response["status-line"], response.status, and response.version.
|
||||
local function parse_status_line(status_line, response)
|
||||
response["status-line"] = status_line
|
||||
local version, status, reason_phrase = string.match(status_line,
|
||||
@@ -665,7 +663,8 @@ local function parse_status_line(status_line, response)
|
||||
if not version then
|
||||
return nil, string.format("Error parsing status-line %q.", status_line)
|
||||
end
|
||||
-- We don't have a use for the version or the reason_phrase; ignore them.
|
||||
-- We don't have a use for the reason_phrase; ignore it.
|
||||
response.version = version
|
||||
response.status = tonumber(status)
|
||||
if not response.status then
|
||||
return nil, string.format("Status code is not numeric: %s", status)
|
||||
|
||||
Reference in New Issue
Block a user