Fix for sending HTTP response status 304 - quark - quark web server | |
git clone git://git.suckless.org/quark | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit b7d0d6889df57e6d288ab4b3ddc1a243558bfa9d | |
parent 9dda0028db2dce035e3dab84b4376c25b21302fa | |
Author: Rainer Holzner <[email protected]> | |
Date: Wed, 22 Apr 2020 20:46:30 +0200 | |
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. | |
Diffstat: | |
M http.c | 1 + | |
M resp.c | 6 ++++-- | |
2 files changed, 5 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/http.c b/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; | |
} | |
} | |
diff --git a/resp.c b/resp.c | |
@@ -216,14 +216,16 @@ resp_file(int fd, char *name, struct request *r, struct s… | |
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; |