lua-users home
lua-l archive

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


Hi Sebastien,

I suppose that file upload support will not be available for a very long
time until I have figured out a sane way to

     1. Parse the raw multipart/formdata properly
     2. actually extract non-formdata (which, just so it happens, is
delivered *exactly* the same way as files are delivered...)
     3. ^^^^^^^^^^^^^ do all that without boilingplate code or risking
crossplatform availability

Currently, that seems like a fairly impossible target, considering that
Perl for example, makes heavy use of its regular expression engine to
parse the data properly.

I'm not sure what cross platform availability means to you (plain Lua only, Windows + UNIX, mainframes, commodore 64 ;-) but you could consider using a proven C parser for multipart/formdata input. You can make it optional so that LunarCGI still works without the binary module (i.e. on all platforms that support Lua) but with reduced functionality in case the binary module is not available.

A bit of searching [1] tells me that there are several C libraries which seem to support this: GMime [2], mimetic [3], cgicc [4] and libapreq [5]. I haven't looked around for Lua bindings to any of these but I'm actually considering writing a binding to libapreq so that I can implement a full featured web server using my Lua/APR binding [6]. If you're interested in such a binding I could probably make it standalone from my (large) Lua/APR binding.

 - Peter Odding

[1] http://stackoverflow.com/questions/2265038/is-there-a-lightweight-multipart-form-data-parser-in-c-or-c
[2] http://spruce.sourceforge.net/gmime/
[3] http://codesink.org/mimetic_mime_library.html
[4] http://www.gnu.org/software/cgicc/
[5] http://httpd.apache.org/apreq/
[6] http://peterodding.com/code/lua/apr/