summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--plop.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/plop.c b/plop.c
index da51251..43f9ed4 100644
--- a/plop.c
+++ b/plop.c
@@ -128,14 +128,18 @@ int handle_client(lua_State * L, struct epoll_event * event)
if (-1 == parse_request(L, (*request)->fd, request))
{
- respond_only_status((*request)->fd, STATUS_BAD_REQUEST);
- return -1; // TODO: Handle errors properly
+ lua_newtable((*request)->lua);
+ lua_pushstring((*request)->lua, "status");
+ lua_pushinteger((*request)->lua, 400); // TODO: How about a function that generates error responses?
+ lua_rawset((*request)->lua, -3);
+ }
+ else // TODO: 0 may mean EAGAIN, stuff will be bad very soon from here.
+ {
+ // TODO: Push the handler to stack earlier to avoid shifting it.
+ lua_getglobal((*request)->lua, "handler");
+ lua_insert((*request)->lua, 1);
+ lua_call((*request)->lua, 5, 1);
}
-
- // TODO: Push the handler to stack earlier to avoid shifting it.
- lua_getglobal((*request)->lua, "handler");
- lua_insert((*request)->lua, 1);
- lua_call((*request)->lua, 5, 1);
int result = response_send((*request)->lua, (*request)->fd);