diff options
author | Aki <please@ignore.pl> | 2020-05-01 16:59:51 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2020-05-01 16:59:51 +0200 |
commit | 0ce61f57957d99d43e77514fa62a5c72f953b2ce (patch) | |
tree | fb6371eecdf15f2ec48bf4df35fd47a9b9a5eb50 | |
parent | 922bb99578b881065048102e03c73ff91c5ad30a (diff) | |
download | plop-0ce61f57957d99d43e77514fa62a5c72f953b2ce.zip plop-0ce61f57957d99d43e77514fa62a5c72f953b2ce.tar.gz plop-0ce61f57957d99d43e77514fa62a5c72f953b2ce.tar.bz2 |
Added string map for methods and fixed statuses
-rw-r--r-- | http.c | 14 | ||||
-rw-r--r-- | http.h | 1 |
2 files changed, 13 insertions, 2 deletions
@@ -2,7 +2,17 @@ #include <stdio.h> -const char * status_string[] = { +const char * method_str[] = { + [METHOD_GET] = "GET", + [METHOD_HEAD] = "HEAD", + [METHOD_POST] = "POST", + [METHOD_PUT] = "PUT", + [METHOD_DELETE] = "DELETE", + [METHOD_OPTIONS] = "OPTIONS", + [METHOD_PATCH] = "PATCH", +}; + +const char * status_str[] = { [STATUS_OK] = "200 OK", [STATUS_BAD_REQUEST] = "400 Bad Request", [STATUS_METHOD_NOT_ALLOWED] = "405 Method Not Allowed", @@ -23,5 +33,5 @@ int respond_only_status(const int fd, const enum status status) "Connection: close\r\n" "\r\n"; - return dprintf(fd, pattern, status_string[status]); + return dprintf(fd, pattern, status_str[status]); } @@ -25,6 +25,7 @@ enum status STATUS_VERSION_NOT_SUPPORTED = 505, }; +extern const char * method_str[]; extern const char * status_str[]; int respond_only_status(int, enum status); |