aboutsummaryrefslogtreecommitdiffstats
path: root/response.c
diff options
context:
space:
mode:
authorkraxel <kraxel>2004-06-10 09:45:50 +0000
committerkraxel <kraxel>2004-06-10 09:45:50 +0000
commit7a9d340846d49f5816c0b2c869ad91b144f7c5c3 (patch)
treeba90d0d7d289336b8f45976bef033cce06734963 /response.c
parentc73269a22b7fdbff11064ef0ab182a4705bf8024 (diff)
downloadwebfs-7a9d340846d49f5816c0b2c869ad91b144f7c5c3.tar.gz
- rewrite timestamp handling: strcmp rfc1123 dates instead of attempt
to parse the date strings.
Diffstat (limited to 'response.c')
-rw-r--r--response.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/response.c b/response.c
index 8f5523d..8c61a9b 100644
--- a/response.c
+++ b/response.c
@@ -172,8 +172,6 @@ static struct HTTP_STATUS {
"Server: %s\r\n" \
"Connection: %s\r\n" \
"Accept-Ranges: bytes\r\n"
-#define RFCTIME \
- "%a, %d %b %Y %H:%M:%S GMT"
#define BOUNDARY \
"XXX_CUT_HERE_%ld_XXX"
@@ -200,7 +198,7 @@ mkerror(struct REQUEST *req, int status, int ka)
req->lres += sprintf(req->hres+req->lres,
"WWW-Authenticate: Basic realm=\"webfs\"\r\n");
req->lres += strftime(req->hres+req->lres,80,
- "Date: " RFCTIME "\r\n\r\n",
+ "Date: " RFC1123 "\r\n\r\n",
gmtime(&now));
req->state = STATE_WRITE_HEADER;
if (debug)
@@ -224,7 +222,7 @@ mkredirect(struct REQUEST *req)
req->hostname,tcp_port,quote(req->path,9999),
(int64_t)req->lbody);
req->lres += strftime(req->hres+req->lres,80,
- "Date: " RFCTIME "\r\n\r\n",
+ "Date: " RFC1123 "\r\n\r\n",
gmtime(&now));
req->state = STATE_WRITE_HEADER;
if (debug)
@@ -255,7 +253,7 @@ mkmulti(struct REQUEST *req, int i)
}
void
-mkheader(struct REQUEST *req, int status, time_t mtime)
+mkheader(struct REQUEST *req, int status)
{
int i;
off_t len;
@@ -300,19 +298,19 @@ mkheader(struct REQUEST *req, int status, time_t mtime)
"Content-Length: %" PRId64 "\r\n",
now, (int64_t)len);
}
- if (mtime != -1) {
- req->lres += strftime(req->hres+req->lres,80,
- "Last-Modified: " RFCTIME "\r\n",
- gmtime(&mtime));
+ if (req->mtime[0] != '\0') {
+ req->lres += sprintf(req->hres+req->lres,
+ "Last-Modified: %s\r\n",
+ req->mtime);
if (-1 != lifespan) {
- expires = mtime + lifespan;
+ expires = req->bst.st_mtime + lifespan;
req->lres += strftime(req->hres+req->lres,80,
- "Expires: " RFCTIME "\r\n",
+ "Expires: " RFC1123 "\r\n",
gmtime(&expires));
}
}
req->lres += strftime(req->hres+req->lres,80,
- "Date: " RFCTIME "\r\n\r\n",
+ "Date: " RFC1123 "\r\n\r\n",
gmtime(&now));
req->state = STATE_WRITE_HEADER;
if (debug)
@@ -331,7 +329,7 @@ mkcgi(struct REQUEST *req, char *status, struct strlist *header)
for (; NULL != header; header = header->next)
req->lres += sprintf(req->hres+req->lres,"%s\r\n",header->line);
req->lres += strftime(req->hres+req->lres,80,
- "Date: " RFCTIME "\r\n\r\n",
+ "Date: " RFC1123 "\r\n\r\n",
gmtime(&now));
req->state = STATE_WRITE_HEADER;
}