libs/lucid-http: use SERVER_ADDR as fallback

This commit is contained in:
Jo-Philipp Wich 2009-06-16 14:41:43 +00:00
parent b3a7ff9f8f
commit 8c359115f9

View file

@ -39,7 +39,7 @@ end
function Redirect.handle_GET(self, request)
local target = self.target
local protocol = request.env.HTTPS and "https://" or "http://"
local server
local server = request.env.SERVER_ADDR
if request.env.REMOTE_ADDR and not request.env.REMOTE_ADDR:find(":") then
local compare = ip.IPv4(request.env.REMOTE_ADDR)
@ -51,9 +51,8 @@ function Redirect.handle_GET(self, request)
end
end
end
else
server = request.env.SERVER_ADDR
end
if server:find(":") then
server = "[" .. server .. "]"
end