From 890ed2ce61a20e7ae14070fc1a76b24e248d0d08 Mon Sep 17 00:00:00 2001 From: Aki Date: Sat, 2 May 2020 14:48:14 +0200 Subject: Added initial method parsing --- http.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'http.c') diff --git a/http.c b/http.c index 264c7b5..6eda100 100644 --- a/http.c +++ b/http.c @@ -82,6 +82,20 @@ int parse_request(const int fd, struct request * const request) return -1; // TODO: Handle errors properly } + for (int i = 0; i < NUMBER_OF_METHODS; ++i) + { + if (0 == strncmp(method_str[i], buffer, strlen(method_str[i]))) + { + request->method = i; + break; + } + + if (NUMBER_OF_METHODS - 1 == i) + { + // TODO: 501 Not Implemented + } + } + request->body = malloc(length + 1); memcpy(request->body, buffer, length); request->body[length] = 0; -- cgit v1.1