[En-Nut-Discussion] MimeHandler questions

Bernd Walter enut at cicely.de
Sun Jun 21 23:13:55 CEST 2009


Questions are already answered after studying the code much longer.

On Sun, Jun 21, 2009 at 02:04:23PM +0200, Bernd Walter wrote:
> Lua is doing it's first hello world via cgi interface.
> Great thanks for all the people doing the integration.
> 
> Now I want something like foo.lua in webroot instead of registering
> cgi function(s).
> NutSetMimeHandler(".lua", HttpProcessLua);
> comes to mind.
> 
> With cgi I fill the request args with the following code:
>         int i;
>         char *name;
>         char *value;
>         lua_newtable(L);
>         int count = NutHttpGetParameterCount(req);
>         for (i = 0; i < count; i++) {
>                 // fill values into lua req;
>                 name = NutHttpGetParameterName (req, i);
>                 value = NutHttpGetParameterValue (req, i);
>                 lua_pushstring(L, name);
>                 lua_pushstring(L, value);
>                 lua_settable(L, -3);
>         }
>         lua_setglobal(L, "args");
> It was not used in my hello world test - be aware of bugs.
> Can I use NutHttpGet* in a mime handler?

It seems the query is already parsed when calling the MimeHandler.
I noticed that POST args are not handled?
NutHttpProcessPostQuery isn't called anywhere despite the fact that
it is compiled in and consumes code space.

> With cgi I send the result with the following code:
>         NutHttpSendHeaderTop(stream, req, error, "Ok");
>         NutHttpSendHeaderBot(stream, (char*)ctype, -1);
>         fputs(page, stream);
> The ASP and SSI code makes me believe that this has to be done
> differently.
> Is modifying the mime type possible at all?

It seems that it isn't possible.
I will just setup a few differend endings: .lua .xlua
It is a bit unfortunate that the input file is already opened, but
quite understandable that the interface is that way.
I will also need to verify if I can directly print to the socket stream
from within Lua instead of keeping the whole page in memory, but it is
ok for the beginning.

-- 
B.Walter <bernd at bwct.de> http://www.bwct.de
Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm.



More information about the En-Nut-Discussion mailing list