From 65870edf9f1e579b4301e1677d70c9387a9a72dc Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Fri, 20 Jun 2008 19:57:57 +0000 Subject: * libs/core: Added garbage collector to luci.util.threadlocal to avoid memory leaks * libs/http: Use env-Variables instead of headers for parse_message_body and subsequent functions * libs/http: Added missing urldecode call for parsing urlencoded params * libs/web: Ported luci.http to use ltn12 sources and sinks instead of sockets or file pointers * libs/sgi-cgi, libs/sgi-webuci, libs/sgi-wsapi: Updated to work with new luci.http.Request ABI --- libs/web/luasrc/http.lua | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'libs/web/luasrc') diff --git a/libs/web/luasrc/http.lua b/libs/web/luasrc/http.lua index f2c3660739..2bd914429e 100644 --- a/libs/web/luasrc/http.lua +++ b/libs/web/luasrc/http.lua @@ -28,6 +28,7 @@ limitations under the License. ]]-- module("luci.http", package.seeall) +require("ltn12") require("luci.http.protocol") require("luci.util") @@ -35,15 +36,10 @@ context = luci.util.threadlocal() Request = luci.util.class() -function Request.__init__(self, env, instream, errstream) - self.input = instream - self.error = errstream - - -- Provide readline function - self.inputreader = self.input.readline - or self.input.read and function() return self.input:read() end - or self.input.receive and function() return self.input:receive() end - or function() return nil end +function Request.__init__(self, env, sourcein, sinkerr) + self.input = sourcein + self.error = sinkerr + -- File handler self.filehandler = function() end @@ -52,13 +48,13 @@ function Request.__init__(self, env, instream, errstream) self.message = { env = env, headers = {}, - params = luci.http.protocol.urldecode_params("?"..(env.QUERY_STRING or "")), + params = luci.http.protocol.urldecode_params(env.QUERY_STRING or ""), } setmetatable(self.message.params, {__index = function(tbl, key) luci.http.protocol.parse_message_body( - self.inputreader, + self.input, self.message, self.filehandler ) -- cgit v1.2.3