summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2020-08-15 16:09:19 +0200
committerAki <please@ignore.pl>2020-08-15 16:09:19 +0200
commitd50c9fbfa635fd06253217897001c85e446c906a (patch)
treefd28d3fe2e657de69d541fde01b74db5fbd189ec
parent80e299845156b605be1a47fdb253d0eea81ce7a2 (diff)
downloadplop-d50c9fbfa635fd06253217897001c85e446c906a.zip
plop-d50c9fbfa635fd06253217897001c85e446c906a.tar.gz
plop-d50c9fbfa635fd06253217897001c85e446c906a.tar.bz2
Moved version parsing to new system
-rw-r--r--plop.c2
-rw-r--r--request.c13
-rw-r--r--request.h1
3 files changed, 8 insertions, 8 deletions
diff --git a/plop.c b/plop.c
index 9748a02..e770a5a 100644
--- a/plop.c
+++ b/plop.c
@@ -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, 3, 1);
+ lua_call((*request)->lua, 4, 1);
size_t length;
const char * body = lua_tolstring((*request)->lua, -1, &length);
diff --git a/request.c b/request.c
index 15c26f3..d67eab7 100644
--- a/request.c
+++ b/request.c
@@ -217,11 +217,11 @@ int parse_step_path(struct request * request)
// TODO: Return -1 if version is unsupported, meaning other than HTTP/1.1
int parse_step_version(struct request * request)
{
- if (0 >= request->version.start)
+ if (0 >= request->temp.start)
{
- request->version.start = read_until_word(request);
+ request->temp.start = read_until_word(request);
- if (0 == request->version.start)
+ if (0 == request->temp.start)
{
return 0;
}
@@ -234,10 +234,11 @@ int parse_step_version(struct request * request)
return 0;
}
- request->version.length = request->position - request->version.start;
- request->step = parse_step_header_name;
+ request->temp.length = request->position - request->temp.start;
- return parse_step_header_name(request);
+ lua_pushlstring(request->lua, request->data + request->temp.start, request->temp.length);
+
+ PROCEED_TO(parse_step_header_name);
}
/// Parses and verifies name of a single header from the request.
diff --git a/request.h b/request.h
index f017fa1..be5ff0e 100644
--- a/request.h
+++ b/request.h
@@ -23,7 +23,6 @@ struct request
lua_State * lua;
int reference;
struct span temp;
- struct span version;
struct header * headerv;
int headerc;
struct span body;