diff options
Diffstat (limited to 'plop.c')
-rw-r--r-- | plop.c | 27 |
1 files changed, 6 insertions, 21 deletions
@@ -109,29 +109,14 @@ int handle_client(lua_State * L, struct pollfd * pfd, struct request ** request, return -1; // TODO: Handle errors properly } - // TODO: Remove debug information or move to logging - printf( - "(%.*s) %.*s\n", - (*request)->version.length, (*request)->data + (*request)->version.start, - (*request)->path.length, (*request)->data + (*request)->path.start); - - for (int h = 0; h < (*request)->headerc; ++h) - { - printf( - "\t'%.*s' = '%.*s'\n", - (*request)->headerv[h].name.length, - (*request)->data + (*request)->headerv[h].name.start, - (*request)->headerv[h].value.length, - (*request)->data + (*request)->headerv[h].value.start); - } - - // TODO: Use results from parsing instead of raw data - lua_getglobal(L, "Handler"); - lua_pushlstring(L, (*request)->data, (*request)->length); - lua_call(L, 1, 1); + // TODO: Push the handler to stack earlier to avoid shifting it. + lua_getglobal((*request)->lua, "Handler"); + lua_insert((*request)->lua, 1); + lua_pushlstring((*request)->lua, (*request)->data, (*request)->length); + lua_call((*request)->lua, 2, 1); size_t length; - const char * body = lua_tolstring(L, -1, &length); + const char * body = lua_tolstring((*request)->lua, -1, &length); if (NULL != body) { |