Commit f93d09b5caaf62fe8de0504f3eb1bcd1c643aa19

Authored by Georg Hopp
1 parent d9193d2e

now Date header will be formatted in GMT as requiered by HTTP protocol

... ... @@ -32,6 +32,13 @@
32 32 #include "utils/memory.h"
33 33 #include "hash.h"
34 34
  35 +static const char *DAY_NAMES[] = {
  36 + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
  37 +static const char *MONTH_NAMES[] = {
  38 + "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  39 + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
  40 +
  41 +
35 42 void
36 43 httpWorkerAddCommonHeader(HttpMessage request, HttpMessage response)
37 44 {
... ... @@ -63,8 +70,11 @@ httpWorkerAddCommonHeader(HttpMessage request, HttpMessage response)
63 70 }
64 71
65 72 t = time(NULL);
66   - tmp = localtime(&t);
67   - nbuf = strftime(buffer, sizeof(buffer), "%a, %d %b %Y %T %Z", tmp);
  73 + tmp = gmtime(&t);
  74 + nbuf = strftime(buffer, sizeof(buffer), "---, %d --- %Y %T GMT", tmp);
  75 + memcpy(buffer, DAY_NAMES[tmp->tm_wday], 3);
  76 + memcpy(buffer+8, MONTH_NAMES[tmp->tm_mon], 3);
  77 +
68 78 hashAdd(response->header,
69 79 new(HttpHeader, CSTRA("Date"), buffer, nbuf));
70 80 }
... ...
Please register or login to post a comment