Fix for sending HTTP response status 304
Stop immediately after responding with status code 304 "Not Modified". This also solves missing log output for status 304. If there is an error while sending a file, try to clean up and close the file.
This commit is contained in:
parent
9dda0028db
commit
b7d0d6889d
2 changed files with 5 additions and 2 deletions
1
http.c
1
http.c
|
@ -541,6 +541,7 @@ http_send_response(int fd, struct request *r)
|
|||
timestamp(time(NULL), t)) < 0) {
|
||||
return S_REQUEST_TIMEOUT;
|
||||
}
|
||||
return S_NOT_MODIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
6
resp.c
6
resp.c
|
@ -216,14 +216,16 @@ resp_file(int fd, char *name, struct request *r, struct stat *st, char *mime,
|
|||
while ((bread = fread(buf, 1, MIN(sizeof(buf),
|
||||
(size_t)remaining), fp))) {
|
||||
if (bread < 0) {
|
||||
return S_INTERNAL_SERVER_ERROR;
|
||||
s = S_INTERNAL_SERVER_ERROR;
|
||||
goto cleanup;
|
||||
}
|
||||
remaining -= bread;
|
||||
p = buf;
|
||||
while (bread > 0) {
|
||||
bwritten = write(fd, p, bread);
|
||||
if (bwritten <= 0) {
|
||||
return S_REQUEST_TIMEOUT;
|
||||
s = S_REQUEST_TIMEOUT;
|
||||
goto cleanup;
|
||||
}
|
||||
bread -= bwritten;
|
||||
p += bwritten;
|
||||
|
|
Loading…
Reference in a new issue