diff options
author | Aki <please@ignore.pl> | 2020-08-15 15:59:08 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2020-08-15 15:59:08 +0200 |
commit | 80e299845156b605be1a47fdb253d0eea81ce7a2 (patch) | |
tree | 0175776f2892317f6233365534677af90f2b324e | |
parent | cf22b1adbbe2e1de5073dcf44b7667a9665a20bf (diff) | |
download | plop-80e299845156b605be1a47fdb253d0eea81ce7a2.zip plop-80e299845156b605be1a47fdb253d0eea81ce7a2.tar.gz plop-80e299845156b605be1a47fdb253d0eea81ce7a2.tar.bz2 |
Moved path parsing to new system
-rw-r--r-- | plop.c | 2 | ||||
-rw-r--r-- | request.c | 15 | ||||
-rw-r--r-- | request.h | 1 |
3 files changed, 10 insertions, 8 deletions
@@ -113,7 +113,7 @@ int handle_client(lua_State * L, struct pollfd * pfd, struct request ** request, lua_getglobal((*request)->lua, "Handler"); lua_insert((*request)->lua, 1); lua_pushlstring((*request)->lua, (*request)->data, (*request)->length); - lua_call((*request)->lua, 2, 1); + lua_call((*request)->lua, 3, 1); size_t length; const char * body = lua_tolstring((*request)->lua, -1, &length); @@ -185,11 +185,12 @@ int parse_step_method(struct request * request) // TODO: Consider spliting path into an actual path and arguments in this stage int parse_step_path(struct request * request) { - if (0 >= request->path.start) + // TODO: Rethink interface of parse_step_* and read_* functions. After a break it looks like mess; it's a bad sign. + if (0 >= request->temp.start) { - request->path.start = read_until_word(request); + request->temp.start = read_until_word(request); - if (0 == request->path.start) + if (0 == request->temp.start) { return 0; } @@ -202,10 +203,12 @@ int parse_step_path(struct request * request) return 0; } - request->path.length = request->position - request->path.start; - request->step = parse_step_version; + request->temp.length = request->position - request->temp.start; - return parse_step_version(request); + // TODO: Use macro for pushing temporary span. Also clear the span in that macro instead of PROCEED_TO. + lua_pushlstring(request->lua, request->data + request->temp.start, request->temp.length); + + PROCEED_TO(parse_step_version); } /// Parses and verifies http version field of the request. @@ -23,7 +23,6 @@ struct request lua_State * lua; int reference; struct span temp; - struct span path; struct span version; struct header * headerv; int headerc; |