diff options
author | Ian C <ianc@noddybox.co.uk> | 2024-12-07 19:28:43 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2024-12-07 19:28:43 +0000 |
commit | 200178c77b5a0fa00827250840481e11fa93bfaa (patch) | |
tree | da3a111a8a9b144a6e13790e7a2050b7fe2c743d | |
parent | 61a191f9c1302ff489c48ca6e9f4ee17bea81a60 (diff) |
Updates to POST logging. Add MacOS debug dir to gitignore.V1.1
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | httpserve.c | 19 |
2 files changed, 16 insertions, 5 deletions
@@ -1 +1,3 @@ httpserve +core +httpserve.dSYM diff --git a/httpserve.c b/httpserve.c index 98045ad..5cbf387 100644 --- a/httpserve.c +++ b/httpserve.c @@ -525,19 +525,25 @@ static void *ThreadCode(void *p) { int file = -1; - printf("Got body of %lu bytes\n", - (unsigned long)content_len); - if (!StrMatch(filename, "/") && (file = open(filename, - O_WRONLY|O_CREAT|O_EXCL)) != -1 && + O_WRONLY|O_CREAT|O_EXCL, + 0664)) != -1 && write(file, contents, content_len) == content_len) { + printf("Wrote %lu bytes to '%s'\n", + (unsigned long)content_len, filename); + GenerateStatus(args->fd, 200, "OK", protocol); } else { + if (file == -1) + { + perror("open"); + } + GenerateStatus(args->fd, 500, "Failed to write contents", protocol); } @@ -568,7 +574,10 @@ static void *ThreadCode(void *p) } else { - printf("Bad request\n"); + if (!close_connection) + { + printf("Bad request\n"); + } } } |