description = [[
Gets the date from HTTP-like services.
]]

---
-- @output
-- 631/tcp open  ipp
-- |_ http-date: Mon, 06 Jul 2009 20:14:41 GMT

author = "David Fifield <david () bamsoftware com>"

license = "Same as Nmap--See http://nmap.org/book/man-legal.html"

categories = {"discovery", "safe"}

require("http")
require("shortport")

portrule = shortport.port_or_service({80, 443, 631, 8080},
	{"http", "https", "ipp", "http-alt"})

action = function(host, port)
	local response = http.get(host, port, "/")
	if response.status then
		return response.header["date"]
	end
end
