diff --git a/ChangeLog b/ChangeLog index a2ee6f63..e6c27181 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ Changes in current version: - o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr. + o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr. o demote most http warnings to debug messages o Fix Solaris compilation; from Magne Mahre + o Add a "Date" header to HTTP responses, as required by HTTP 1.1. \ No newline at end of file diff --git a/http.c b/http.c index 359c1702..da43eb08 100644 --- a/http.c +++ b/http.c @@ -64,9 +64,10 @@ #include #endif #include -#ifdef HAVE_TIME_H -#include +#ifdef HAVE_SYS_TIME_H +#include #endif +#include #include #include @@ -351,6 +352,18 @@ evhttp_make_header_response(struct evhttp_connection *evcon, /* Potentially add headers for unidentified content. */ if (EVBUFFER_LENGTH(req->output_buffer)) { + if (evhttp_find_header(req->output_headers, + "Date") == NULL) { + char date[50]; + struct tm cur; + time_t t = time(NULL); + gmtime_r(&t, &cur); + if (strftime(date, sizeof(date), + "%a, %d %b %Y %H:%M:%S GMT", &cur) != 0) { + evhttp_add_header(req->output_headers, "Date", date); + } + } + if (evhttp_find_header(req->output_headers, "Content-Type") == NULL) { evhttp_add_header(req->output_headers,