summaryrefslogtreecommitdiff
path: root/include/http.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/http.h')
-rw-r--r--include/http.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/include/http.h b/include/http.h
new file mode 100644
index 0000000..c550b15
--- /dev/null
+++ b/include/http.h
@@ -0,0 +1,41 @@
+#ifndef _HTTP_H_
+#define _HTTP_H_
+#include <stdbool.h>
+
+#include "buffer.h"
+
+//static const char *supported_http_versions[] = { "1.1" };
+
+struct header_item;
+#define MAX_HEADERS 512
+struct header_list {
+ struct header_item *items[MAX_HEADERS];
+};
+
+struct request {
+ char http_version[4];
+ char *method;
+ char *path;
+ char *query;
+ char *body;
+ char *data;
+ struct header_list header;
+};
+
+struct reply {
+ int status;
+ char *body;
+};
+
+typedef struct reply *(request_callback)(struct request *, void *);
+
+struct http;
+
+struct http *http_init(void);
+bool http_register_handler(struct http *http, char *method, char *path,
+ void *data, request_callback *callback);
+struct reply *http_handle_request(struct http *http, struct buffer *req);
+struct buffer *http_build_reply(struct reply *reply);
+const char *http_get_header(struct request *req, const char *key);
+
+#endif