Changeset

4659:d53142e90cd0

net.http.server: Fix legacy net.httpserver fallback (httpserver is no longer a global).
author Waqas Hussain <waqas20@gmail.com>
date Sun, 22 Apr 2012 23:44:21 +0500
parents 4658:de04897cb8fe
children 4660:96b40b5e8ea8
files net/http/server.lua
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/net/http/server.lua	Sun Apr 22 23:43:34 2012 +0500
+++ b/net/http/server.lua	Sun Apr 22 23:44:21 2012 +0500
@@ -13,6 +13,7 @@
 local tostring = tostring;
 local codes = require "net.http.codes";
 local _G = _G;
+local legacy_httpserver = require "net.httpserver";
 
 local _M = {};
 
@@ -159,9 +160,9 @@
 function _M.legacy_handler(request, response)
 	log("debug", "Invoking legacy handler");
 	local base = request.path:match("^/([^/?]+)");
-	local legacy_server = _G.httpserver and _G.httpserver.new.http_servers[5280];
+	local legacy_server = legacy_httpserver and legacy_httpserver.new.http_servers[5280];
 	local handler = legacy_server and legacy_server.handlers[base];
-	if not handler then handler = _G.httpserver and _G.httpserver.set_default_handler.default_handler; end
+	if not handler then handler = legacy_httpserver and legacy_httpserver.set_default_handler.default_handler; end
 	if handler then
 		-- add legacy properties to request object
 		request.url = { path = request.path };