lua-users home
lua-l archive

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


Hey, I'm happy to announce that I finally found a pure Lua way to
parse multipart in LunarCGI!

The code is 'borrowed' from the LuaCheia project
(http://luacheia.lua-users.org/, src/modules/cgi/cgi.lua).

So far, it works flawlessly, except for one major problem:
I'm unable to split the data correctly :(

The data returned by LunarCore.process_multipart_post looks like this
(returned as key->value table):

   Content-Type: text/plain

   <actual content of the file>

That is, 'Content-Type: <mimetype>' + two newlines + actual data.

I haven't been able to properly split the Content-Type from the data,
since my knowledge of Lua pattern matching is rather limited.

I tried to split it with string.gfind: string.gfind(s, "Content-Type:
%a+/%a+\n\n(.-)"), with no avail, and I'm seriously lost here.

I've asked on IRC as well, but apparently it's either a little bit too
early (or too late?) right now, and i'm stuck.

In the current version
(https://github.com/beelzebub/LunarCGI/blob/master/LunarCGI.lua#L185)
I tried to split it the oldfashioned way with LunarCore.split(),
however, that didn't work either.

If anyone is more handy with Lua pattern matching than me, I would
appreciate a little help here :-)

Apart from that, File uploads will be available pretty much as soon as
this problem is solved :-)