added date header to response

Sat, 17 Oct 2015 23:05:23 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 17 Oct 2015 23:05:23 +0200
changeset 103
d3b514e2ddbd
parent 102
136a76e293b5
child 104
a8acbb12f27c

added date header to response

src/server/daemon/protocol.c file | annotate | diff | comparison | revisions
src/server/util/util.c file | annotate | diff | comparison | revisions
--- a/src/server/daemon/protocol.c	Sat Oct 17 22:24:38 2015 +0200
+++ b/src/server/daemon/protocol.c	Sat Oct 17 23:05:23 2015 +0200
@@ -32,7 +32,7 @@
 #include "../util/pool.h"
 #include "session.h"
 #include "../util/io.h"
-
+#include "../util/util.h"
 #include "../util/strbuf.h"
 
 
@@ -309,6 +309,15 @@
     // add server header
     sbuf_write(out, "Server: webserver\r\n", 19);
     
+    // add date header
+    struct tm mtms;
+    struct tm *mtm = system_gmtime(&rq->req_start, &mtms);
+    char date[HTTP_DATE_LEN + 1];
+    strftime(date, HTTP_DATE_LEN, HTTP_DATE_FMT, mtm);
+    sbuf_write(out, "Date: ", 6);
+    sbuf_write(out, date, strlen(date));
+    sbuf_write(out, "\r\n", 2);
+    
     // check content length ans transfer encoding
     char *ctlen = pblock_findkeyval(pb_key_content_length, rq->srvhdrs);
     char *enc = pblock_findkeyval(pb_key_transfer_encoding, rq->srvhdrs);
--- a/src/server/util/util.c	Sat Oct 17 22:24:38 2015 +0200
+++ b/src/server/util/util.c	Sat Oct 17 23:05:23 2015 +0200
@@ -607,10 +607,12 @@
 
 static const int MSTR2NUM_HT_MASK = 0xf;
 
-static const struct {
+struct mstr2num_ht {
     unsigned ucmstr; // Uppercase 3 character month string in a machine word
     int mnum; // 0-based month number for this month string
-} MSTR2NUM_HT[MSTR2NUM_HT_MASK + 1] = {
+};
+
+struct mstr2num_ht MSTR2NUM_HT[] = {
     { 'A' << 16 | 'P' << 8 | 'R', 3 },
     { 'S' << 16 | 'E' << 8 | 'P', 8 },
     { 'M' << 16 | 'A' << 8 | 'Y', 4 },

mercurial