|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
MimeHandler questionsLua 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? 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? -- B.Walter <bernd@...> http://www.bwct.de Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm. _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: MimeHandler questionsQuestions 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@...> http://www.bwct.de Modbus/TCP Ethernet I/O Baugruppen, ARM basierte FreeBSD Rechner uvm. _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: MimeHandler questionsHi!
> 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. You have to call it in your own code. This makes sense as sometimes you might not want to parse the post data into name = value tuples but read the data as is (uploading a file, sending custom data, ...). The code will like somewhat similiar like this: NutHttpProcessPostQuery(stream, req); count = NutHttpGetParameterCount(req); for (idx = 0; idx < count; idx++) { name = NutHttpGetParameterName(req, idx); value = NutHttpGetParameterValue(req, idx); > > 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 The function you need is NutSetMimeHandler(".lua", NutHttpProcess....); Indeed the current api is not very comfortable in every place but designed as a very liteweight design. Bye, Ole Reinhardt -- _____________________________________________________________ | | | Embedded-IT | | | | Ole Reinhardt Tel. / Fax: +49 (0)271 7420433 | | Luisenstraße 29 Mobil: +49 (0)177 7420433 | | 57076 Siegen eMail: ole.reinhardt@... | | Germany Web: http://www.embedded-it.de | |_____________________________________________________________| _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
| Free embeddable forum powered by Nabble | Forum Help |