From 1ebb9bfe20e98e185cd5831f2cb34af058df50ff Mon Sep 17 00:00:00 2001 From: david Date: Sat, 2 Mar 2013 01:05:32 +0000 Subject: [PATCH] Don't include a port number in the Host header. We never intend to ask for a service on a port other than the one we connect to. By my reading of RFC 2616 section 14.23, we can leave the port number off in this case. Robin Wood reported that https://twitter.com/ gives you a redirect instead of a page if you send it Host: twitter.com:443 rather than Host: twitter.com http://seclists.org/nmap-dev/2013/q1/267 --- nselib/http.lua | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/nselib/http.lua b/nselib/http.lua index d10730ea4..34e2d0c6e 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -147,21 +147,9 @@ local function table_augment(to, from) end --- Get a value suitable for the Host header field. +-- See RFC 2616 sections 14.23 and 5.2. local function get_host_field(host, port) - local hostname = stdnse.get_hostname(host) - local portno - if port == nil then - portno = 80 - elseif type(port) == "table" then - portno = port.number - else - portno = port - end - if portno == 80 then - return hostname - else - return hostname .. ":" .. tostring(portno) - end + return stdnse.get_hostname(host) end -- Skip *( SP | HT ) starting at offset. See RFC 2616, section 2.2.