From c39a8e4ca2099683cb48fcef8b6f5443e05f3c83 Mon Sep 17 00:00:00 2001 From: Gerard Hickey Date: Sun, 5 May 2024 15:14:33 -0400 Subject: [PATCH] Replace luci calls with pure Lua code Signed-off-by: Gerard Hickey --- meshchat | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/meshchat b/meshchat index 3efb354..f0bad74 100755 --- a/meshchat +++ b/meshchat @@ -37,26 +37,29 @@ package.path = package.path .. ";/www/cgi-bin/?.lua" -require('luci.http') -require("meshchatconfig") local json = require("json") local lib = require("meshchatlib") +local url = require("net/url") +require("meshchatconfig") --- -- @module meshchat local query = {} local uploadfilename -if os.getenv("QUERY_STRING") ~= "" or os.getenv("REQUEST_METHOD") == "POST" then - local request = luci.http.Request(lib.getenv(), - function() - local v = io.read(1024) - if not v then - io.close() - end - return v - end - ) + +if os.getenv("QUERY_STRING") ~= "" then + -- Process a GET request + query = url.parseQuery(os.getenv("QUERY_STRING")) +elseif os.getenv("REQUEST_METHOD") == "POST" then + -- Process a POST request + local request = '' + while v = io.read(1024) do + request = request .. v + end + + query = url.parseQuery(request) + local fp request:setfilehandler( function(meta, chunk, eof)