lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Tomas,

Tomas wrote:

The preprocess() function always calls htmlheader() before
includehtml(). At this point no header was sent (because the page was
never processed) and the htnlheader() function would always send the
Content-type header.


Yes. What is the problem with that? Could you send us
an example?



I've written a Lua module with functions that are to be called from a Lua page. The first thing the Lua page does is 'cgilua.doscript "./lib/colablib.lua"' (I couldn't get require to import a module not in the standard path) and then comes some static content. The problem arises when the page receives "action=save" as an argument; in this case the code in colablib.lua is supposed to save some data to disk and redirects to cgilua.script_vpath again with "action=view". But as Content-type was already sent by CGILua, my Location header is rendered useless.


--- BEGIN CODE ---
<?lua
cgilua.doscript "./lib/colablib.lua"
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<title><?lua= colab.currentPage() ?> -
<?lua= colab.wikiName() ?></title>
<meta name="generator" content="ColabWiki <?lua= colab.version() ?>" />
</head>
<body>
<h1 id="header"><?lua= colab.currentPage() ?></h1>


       <div id="content">
       <?lua= colab.getContent() ?>
       </div>
</body>
</html>
--- END CODE ---

-alex