According to the mod_lua documentation, there should be a function called r:parsebody, which parses the POST data and converts it into a Lua table, but I have yet to actually find this function declared inside the mod_lua code. With 2.4, adding this functionality should be pretty straightforward: /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* r:parsebody() returning a lua table */ static int req_parsebody(lua_State *L) { apr_array_header_t *fields; int i; apr_table_entry_t *e = 0; request_rec *r = ap_lua_check_request_rec(L, 1); lua_newtable(L); lua_newtable(L); /* [table, table] */ ap_parse_form_data(r, NULL, &fields, -1, MAX_STRING_LEN); /* Maybe increase this value? */ e = (apr_table_entry_t *) fields->elts; for(i = 0; i < fields->nelts; i++) { req_aprtable2luatable_cb(L, e[i].key, e[i].val); } return 2; /* [table<string, string>, table<string, array<string>>] */ } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ (The function would also have to be declared in ap_lua_load_request_lmodule) I hope this little snippet will at least give some food for thought, and I hope that the issue can be resolved at some point in time, as we clearly need more Lua in the world.
IMO mod_lua enhancement or doc defect -- setting to enhancement
Created attachment 28968 [details] Patch for adding the parsebody function This patch adds the parsebody function to the Lua environment, so scripts can access POST data from requests.
Added the function to trunk, r1352047
Applied in r1365539 to 2.4.x. Released with 2.4.3.