summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--http.c14
-rw-r--r--http.h1
2 files changed, 13 insertions, 2 deletions
diff --git a/http.c b/http.c
index 706b982..dc0e9c8 100644
--- a/http.c
+++ b/http.c
@@ -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]);
}
diff --git a/http.h b/http.h
index cef3048..f92f7fc 100644
--- a/http.h
+++ b/http.h
@@ -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);