[hackers] [quark] Improve timestamp() semantics || Laslo Hunhold
commit c0a2c5de0a6a88445c09e1e974899f6b8fb3c73e
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Tue Jul 4 21:47:28 2017 +0200
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Tue Jul 4 21:47:28 2017 +0200
Improve timestamp() semantics
Thanks Hiltjo! We are now in the enterprise(tm)!
diff --git a/quark.c b/quark.c
index 19c7a79..b0708cf 100644
--- a/quark.c
+++ b/quark.c
_AT_@ -98,9 +98,6 @@ static char *status_str[] = {
static char *
timestamp(time_t t, char buf[TIMESTAMP_LEN])
{
- if (!t) {
- t = time(NULL);
- }
strftime(buf, TIMESTAMP_LEN, "%a, %d %b %Y %T GMT", gmtime(&t));
return buf;
_AT_@ -158,7 +155,7 @@ sendstatus(int fd, enum status s)
"<!DOCTYPE html>\n<html>\n\t<head>\n"
"\t\t<title>%d %s</title>\n\t</head>\n\t<body>\n"
"\t\t<h1>%d %s</h1>\n\t</body>\n</html>\n",
- s, status_str[s], timestamp(0, t),
+ s, status_str[s], timestamp(time(NULL), t),
(s == S_METHOD_NOT_ALLOWED) ? "Allow: HEAD, GET\r\n" : "",
s, status_str[s], s, status_str[s]) < 0) {
return S_REQUEST_TIMEOUT;
_AT_@ -357,7 +354,7 @@ senddir(int fd, char *name, struct request *r)
"Connection: close\r\n"
"Content-Type: text/html\r\n"
"\r\n",
- S_OK, status_str[S_OK], timestamp(0, t)) < 0) {
+ S_OK, status_str[S_OK], timestamp(time(NULL), t)) < 0) {
s = S_REQUEST_TIMEOUT;
goto cleanup;
}
_AT_@ -442,7 +439,7 @@ sendfile(int fd, char *name, struct request *r, struct stat *st, char *mime,
"Last-Modified: %s\r\n"
"Content-Type: %s\r\n"
"Content-Length: %zu\r\n",
- s, status_str[s], timestamp(0, t1),
+ s, status_str[s], timestamp(time(NULL), t1),
timestamp(st->st_mtim.tv_sec, t2), mime, upper - lower + 1) < 0) {
s = S_REQUEST_TIMEOUT;
goto cleanup;
_AT_@ -590,8 +587,8 @@ sendresponse(int fd, struct request *r)
"Location: %s\r\n"
"\r\n",
S_MOVED_PERMANENTLY,
- status_str[S_MOVED_PERMANENTLY], timestamp(0, t),
- tmptarget) < 0) {
+ status_str[S_MOVED_PERMANENTLY],
+ timestamp(time(NULL), t), tmptarget) < 0) {
return S_REQUEST_TIMEOUT;
}
_AT_@ -638,7 +635,7 @@ sendresponse(int fd, struct request *r)
"Connection: close\r\n"
"\r\n",
S_NOT_MODIFIED, status_str[S_NOT_MODIFIED],
- timestamp(0, t)) < 0) {
+ timestamp(time(NULL), t)) < 0) {
return S_REQUEST_TIMEOUT;
}
}
_AT_@ -679,7 +676,7 @@ sendresponse(int fd, struct request *r)
"\r\n",
S_RANGE_NOT_SATISFIABLE,
status_str[S_RANGE_NOT_SATISFIABLE],
- timestamp(0, t),
+ timestamp(time(NULL), t),
st.st_size) < 0) {
return S_REQUEST_TIMEOUT;
}
Received on Tue Jul 04 2017 - 21:47:56 CEST
This archive was generated by hypermail 2.3.0
: Tue Jul 04 2017 - 21:48:44 CEST