summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--request.c16
-rw-r--r--request.h1
2 files changed, 17 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.
diff --git a/request.h b/request.h
index 26284f0..723908f 100644
--- a/request.h
+++ b/request.h
@@ -23,6 +23,7 @@ struct request
lua_State * lua;
int reference;
struct span temp;
+ int expected_data_length;
};
struct request * new_request(lua_State *);