libs/lucid-http: use SERVER_ADDR as fallback
authorJo-Philipp Wich <jow@openwrt.org>
Tue, 16 Jun 2009 14:41:43 +0000 (14:41 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Tue, 16 Jun 2009 14:41:43 +0000 (14:41 +0000)
libs/lucid-http/luasrc/lucid/http/handler/catchall.lua

index a5cdce53417a239709d9a5f27a7bb77d073e130b..13272d91e4651bc6fadb9455638fd2fe93e54ca6 100644 (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
@@ -85,4 +84,4 @@ Redirect.handle_POST = Redirect.handle_GET
 function Redirect.handle_HEAD(self, request)
        local stat, head = self:handle_GET(request)
        return stat, head
-end
\ No newline at end of file
+end