Since mg.read() doesn't actually exist, what is the solution to read input parameters sent through either GET or POST?
On Friday, January 31, 2014 5:02:37 PM UTC+1, Gilles wrote: > > If mg.read() isn't available, does it mean I have to find some Lua module > to handle CGI so that input parameters are somehow available to the script? > > On Friday, January 31, 2014 4:55:48 PM UTC+1, Gilles wrote: >> >> Thanks for the info. >> >> I tried mg.read() because it's used in examples/lua/prime_numbers.lp . >> >> On Thursday, January 30, 2014 6:41:23 PM UTC+1, Sergey Lyubka wrote: >>> >>> To use onerror, do: >>> >>> mg.onerror = function(err) >>> -- do whatever you want >>> end >>> >>> Note that documentation says nothing about mg.read(). >>> The reason is mg.read() doesn't exist. >>> >>> >>> On Thu, Jan 30, 2014 at 4:44 PM, Gilles <[email protected]> wrote: >>> >>>> Hello >>>> >>>> Nothing is displayed when calling the following Lua script from a form: >>>> >>>> *form.html* >>>> <form action="cgi.lp" method="post"> >>>> <input type=text" name="dummy"> >>>> <input type="submit" value="Submit"> >>>> </form> >>>> >>>> *cgi.lp* >>>> HTTP/1.0 200 OK >>>> Content-Type: text/plain >>>> >>>> <? >>>> local post_data = '' >>>> if mg.request_info.request_method == 'POST' then >>>> post_data = mg.read() >>>> end >>>> mg.write(post_data) >>>> >>>> mg.write(mg.request_info.request_method) >>>> mg.write(mg.request_info.remote_ip, ':', mg.request_info.remote_port) >>>> mg.write(mg.request_info.uri) >>>> mg.write(mg.request_info.http_version) >>>> for name, value in pairs(mg.request_info.http_headers) do >>>> mg.write(name, ':', value, '\n') >>>> end >>>> ?> >>>> >>>> The page is blank, and no error message is available in the console. >>>> >>>> The documentation <http://cesanta.com/docs.html?LuaSqlite.md> mentions >>>> "mg.onerror(msg)": Would this help investigate, and if yes, how? >>>> >>>> Thank you. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "mongoose-users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at http://groups.google.com/group/mongoose-users. >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>> >>> -- You received this message because you are subscribed to the Google Groups "mongoose-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/mongoose-users. For more options, visit https://groups.google.com/groups/opt_out.
