[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [CGILua 5.0b2] Possible bug and change request
- From: Alex Sandro Queiroz e Silva <ventonegro@...>
- Date: Sun, 09 Jan 2005 14:52:47 -0300
Hallo all,
It seems that there is a bug in CGILua 5.0 beta 2. The variable
cgilua.script_path is advertised as the path of the currently running
script but evaluates to a boolean. cgilua.script_vpath is fine.
And I'd like to make a request to change the behaviour of the
preprocess() function. Right now it always sends the text/html header
before sending the processed Lua page. But this hurts HTTP redirects
since a header was already sent. Attached there is a patch for CGILua,
this patches it to only send the header just before the first static
content is sent. This is somewhat like the way PHP works too, BTW.
-alex
diff -Nru cgilua-5.0b2/clmain/cgilua/cgilua.lua cgilua-5.0b2.mod/clmain/cgilua/cgilua.lua
--- cgilua-5.0b2/clmain/cgilua/cgilua.lua 2004-12-22 16:31:19.000000000 -0300
+++ cgilua-5.0b2.mod/clmain/cgilua/cgilua.lua 2005-01-09 14:42:05.000000000 -0300
@@ -208,7 +208,7 @@
-- preprocessed HTML )
----------------------------------------------------------------------------
function preprocess (filename)
- htmlheader ()
+-- htmlheader ()
includehtml (filename)
end
diff -Nru cgilua-5.0b2/clmain/cgilua/prep.lua cgilua-5.0b2.mod/clmain/cgilua/prep.lua
--- cgilua-5.0b2/clmain/cgilua/prep.lua 2004-12-22 16:31:19.000000000 -0300
+++ cgilua-5.0b2.mod/clmain/cgilua/prep.lua 2005-01-09 14:42:09.000000000 -0300
@@ -28,6 +28,7 @@
function translate (s)
+ local header_not_sent = true
if compatmode then
s = gsub(s, "$|(.-)|%$", "<?lua = %1 ?>")
s = gsub(s, "<!%-%-$$(.-)$$%-%->", "<?lua %1 ?>")
@@ -38,6 +39,10 @@
while true do
local ip, fp, target, exp, code = find(s, "<%?(%w*)%s*(=?)(.-)%?>", start)
if not ip then break end
+ if header_not_sent and ip ~= start then
+ header_not_sent = false
+ tinsert(res, out("Content-type: text/html\r\n\r\n", 1))
+ end
tinsert(res, out(s, start, ip-1))
if target ~= "" and target ~= "lua" then
-- not for Lua; pass whole instruction to the output