From 4de3158c80864aa130ac6f701f4c28a2aa7bbf20 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 17 Jul 2019 21:25:15 -0400 Subject: move HTTP POST handling to separate file --- blog.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'blog.c') diff --git a/blog.c b/blog.c index d3c8e49..4c7f3db 100644 --- a/blog.c +++ b/blog.c @@ -1,14 +1,34 @@ +#define _XOPEN_SOURCE 700 #include #include -#include #include +#include "blog.h" extern char **environ; +int verify_creds(const char *username, const char *password) +{ + printf("verifying '%s'/'%s'\n", username ? username : "", password ? password : ""); + return 1; +} + int handle_post(void) { - printf("Status: 301 Found\r\n"); - printf("Location: http%s://%s%s\r\n\r\n", getenv("HTTPS") ? "s" : "", getenv("HTTP_HOST"), getenv("DOCUMENT_URI")); + + //printf("Status: 301 Found\r\n"); + //printf("Location: http%s://%s%s\r\n\r\n", getenv("HTTPS") ? "s" : "", getenv("HTTP_HOST"), getenv("DOCUMENT_URI")); + + printf("Status: 200 OK\r\n"); + printf("Content-Type: text/plain\r\n\r\n"); + + read_post_data(); + if (!verify_creds(find_post_data("username"), find_post_data("password"))) { + // handle invalid login + } + + for (char **e = environ; e && *e; e++) { + puts(*e); + } return 0; } @@ -51,11 +71,11 @@ int main(void) puts(""); puts(""); - puts("
");
+	puts("");
 
 	puts("");
 	puts("");
-- 
cgit v1.2.1