summaryrefslogtreecommitdiff
path: root/httpserve.c
diff options
context:
space:
mode:
Diffstat (limited to 'httpserve.c')
-rw-r--r--httpserve.c19
1 files changed, 14 insertions, 5 deletions
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");
+ }
}
}