summaryrefslogtreecommitdiffhomepage
path: root/request.c
diff options
context:
space:
mode:
Diffstat (limited to 'request.c')
-rw-r--r--request.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/request.c b/request.c
index 7902f1f..e0956b4 100644
--- a/request.c
+++ b/request.c
@@ -281,6 +281,12 @@ int parse_step_header_name(struct request * request)
request->temp.length = request->position - request->temp.start;
+ if (0 == strncasecmp("content-length", request->data + request->temp.start, request->temp.length))
+ {
+ // TODO: While it shouldn't happen, use a flag instead of a magic value.
+ request->expected_data_length = -1;
+ }
+
lua_pushlstring(request->lua, request->data + request->temp.start, request->temp.length);
// Skip ':'
@@ -312,8 +318,18 @@ int parse_step_header_value(struct request * request)
request->temp.length = request->position - request->temp.start;
+ if (-1 == request->expected_data_length)
+ {
+ *(request->data + request->temp.start + request->temp.length) = 0;
+ request->expected_data_length = atoi(request->data + request->temp.start);
+ *(request->data + request->temp.start + request->temp.length) = '\r';
+ }
+
lua_pushlstring(request->lua, request->data + request->temp.start, request->temp.length);
lua_rawset(request->lua, -3);
PROCEED_TO(parse_step_header_name);
}
+
+// TODO: Pass data payload to Lua state.
+// TODO: Make a table from the request.