Properly serve empty files

This commit is contained in:
Laslo Hunhold 2017-07-11 12:33:21 +02:00
parent af61e37a3a
commit 9e9facc9bf

View file

@ -444,7 +444,8 @@ sendfile(int fd, char *name, struct request *r, struct stat *st, char *mime,
"Content-Type: %s\r\n" "Content-Type: %s\r\n"
"Content-Length: %zu\r\n", "Content-Length: %zu\r\n",
s, status_str[s], timestamp(time(NULL), t1), s, status_str[s], timestamp(time(NULL), t1),
timestamp(st->st_mtim.tv_sec, t2), mime, upper - lower + 1) < 0) { timestamp(st->st_mtim.tv_sec, t2), mime,
upper - lower + (st->st_size > 0)) < 0) {
s = S_REQUEST_TIMEOUT; s = S_REQUEST_TIMEOUT;
goto cleanup; goto cleanup;
} }