do not cache 404 responses
This commit is contained in:
parent
79d7558148
commit
c90521b740
20
main.c
20
main.c
|
@ -317,16 +317,22 @@ send_file(int fd, char *file, char *type, int chunked, int size, int cache)
|
|||
}
|
||||
}
|
||||
|
||||
if ((ifd = open(file, O_RDONLY)) < 0)
|
||||
{
|
||||
/* Don't set caching for the 404 response. */
|
||||
cache = 0;
|
||||
|
||||
if ((ifd = open("404.html", O_RDONLY)) < 0)
|
||||
{
|
||||
headers(fd, "text/plain", NULL, 0);
|
||||
send_fd(fd, "Error opening %s\n", file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (type)
|
||||
headers(fd, type, NULL, cache);
|
||||
|
||||
if ((ifd = open(file, O_RDONLY)) < 0 &&
|
||||
(ifd = open("404.html", O_RDONLY)) < 0)
|
||||
{
|
||||
send_fd(fd, "Error opening %s\n", file);
|
||||
return;
|
||||
}
|
||||
|
||||
fstat(ifd, &st);
|
||||
|
||||
if (size <= 0 || size > st.st_size)
|
||||
|
|
Loading…
Reference in New Issue