commit fd582d92278a1714c0e1fe40b14e944a6229e73b
parent daf2460bd760556adebaa5c4865ad5f9d5d2808f
Author: William Casarin <jb55@jb55.com>
Date: Thu, 3 Dec 2020 16:55:38 -0800
wip handle request
Diffstat:
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/wolfsocks.c b/src/wolfsocks.c
@@ -16,12 +16,25 @@
#define BUF_SIZE 4096
#define ARENA_SIZE 8192
+struct request {
+ struct http_req http_req;
+ struct
+}
+
static void error(char *msg)
{
perror(msg);
exit(1);
}
+static void handle_request(struct http_req *req)
+{
+ if (!strcmp(req->method, "POST") &&
+ (!strcmp(req->path, "/inbox") ||
+ !strcmp(req->path, "/inbox/"))) {
+ print_http_request(req);
+ }
+}
void run_http_server()
{
@@ -101,13 +114,7 @@ void run_http_server()
}
if (parse_http_request(&req, &parser)) {
- printf("\nPARSED:\n\n");
- print_http_request(&req);
- }
-
- printf("\nRAW:\n\n");
- if (write(1, buffer, len) == -1) {
- perror("write");
+ handle_request(&req);
}
if (len != BUF_SIZE) {