diff options
| -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"); +            }          }      } | 
