summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2020-08-15 15:23:53 +0200
committerAki <please@ignore.pl>2020-08-15 15:23:53 +0200
commit162c05ece12525e684d05ed620a6ffa74d561fa8 (patch)
treea5b5f37dbe6be912c92ae938edcc19ad6f7eecb5
parent92be962c748d5a45da4bf207a7b17c2b25ca31cd (diff)
downloadplop-162c05ece12525e684d05ed620a6ffa74d561fa8.zip
plop-162c05ece12525e684d05ed620a6ffa74d561fa8.tar.gz
plop-162c05ece12525e684d05ed620a6ffa74d561fa8.tar.bz2
Moved parsed method to lua state
-rw-r--r--plop.c3
-rw-r--r--request.c9
-rw-r--r--request.h2
3 files changed, 8 insertions, 6 deletions
diff --git a/plop.c b/plop.c
index 45d913f..51721b6 100644
--- a/plop.c
+++ b/plop.c
@@ -111,9 +111,8 @@ int handle_client(lua_State * L, struct pollfd * pfd, struct request ** request,
// TODO: Remove debug information or move to logging
printf(
- "(%.*s) [%.*s] %.*s\n",
+ "(%.*s) %.*s\n",
(*request)->version.length, (*request)->data + (*request)->version.start,
- (*request)->method.length, (*request)->data + (*request)->method.start,
(*request)->path.length, (*request)->data + (*request)->path.start);
for (int h = 0; h < (*request)->headerc; ++h)
diff --git a/request.c b/request.c
index e8f47b0..3e67ff8 100644
--- a/request.c
+++ b/request.c
@@ -160,15 +160,18 @@ static int read_rest_of_line(struct request * request)
/// \return -1 if an error has occured, 0 if too little data available or total number of bytes processed
int parse_step_method(struct request * request)
{
- request->method.length = read_until_char(request, ' ');
+ request->temp.start = 0;
+ // TODO: Consider reworking read_* functions to be more aware of word boundaries.
+ request->temp.length = read_until_char(request, ' ');
- if (0 == request->method.length)
+ if (0 == request->temp.length)
{
return 0;
}
- request->step = parse_step_path;
+ lua_pushlstring(request->lua, request->data + request->temp.start, request->temp.length);
+ request->step = parse_step_path;
return parse_step_path(request);
}
diff --git a/request.h b/request.h
index 79aca75..b29bf0e 100644
--- a/request.h
+++ b/request.h
@@ -22,7 +22,7 @@ struct request
int position;
lua_State * lua;
int reference;
- struct span method;
+ struct span temp;
struct span path;
struct span version;
struct header * headerv;