Browse Source

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

release0.1.5
Georg Hopp 12 years ago
parent
commit
f93d09b5ca
  1. 14
      src/http/worker/add_common_header.c

14
src/http/worker/add_common_header.c

@ -32,6 +32,13 @@
#include "utils/memory.h" #include "utils/memory.h"
#include "hash.h" #include "hash.h"
static const char *DAY_NAMES[] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
static const char *MONTH_NAMES[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
void void
httpWorkerAddCommonHeader(HttpMessage request, HttpMessage response) httpWorkerAddCommonHeader(HttpMessage request, HttpMessage response)
{ {
@ -63,8 +70,11 @@ httpWorkerAddCommonHeader(HttpMessage request, HttpMessage response)
} }
t = time(NULL); t = time(NULL);
tmp = localtime(&t);
nbuf = strftime(buffer, sizeof(buffer), "%a, %d %b %Y %T %Z", tmp);
tmp = gmtime(&t);
nbuf = strftime(buffer, sizeof(buffer), "---, %d --- %Y %T GMT", tmp);
memcpy(buffer, DAY_NAMES[tmp->tm_wday], 3);
memcpy(buffer+8, MONTH_NAMES[tmp->tm_mon], 3);
hashAdd(response->header, hashAdd(response->header,
new(HttpHeader, CSTRA("Date"), buffer, nbuf)); new(HttpHeader, CSTRA("Date"), buffer, nbuf));
} }

Loading…
Cancel
Save