summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2024-12-07 19:28:43 +0000
committerIan C <ianc@noddybox.co.uk>2024-12-07 19:28:43 +0000
commit200178c77b5a0fa00827250840481e11fa93bfaa (patch)
treeda3a111a8a9b144a6e13790e7a2050b7fe2c743d
parent61a191f9c1302ff489c48ca6e9f4ee17bea81a60 (diff)
Updates to POST logging. Add MacOS debug dir to gitignore.V1.1
-rw-r--r--.gitignore2
-rw-r--r--httpserve.c19
2 files changed, 16 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index af7d53d..97beab7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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");
+ }
}
}