On 22/08/07, Elliot Foster <[EMAIL PROTECTED]> wrote:
> Ralph Moritz wrote:
> > Good point.After submitting this,I also realized that I forgot to
> > check the return value of strftime().
>
> For that matter, why limit it to 1.1?  1.0 allows the Date header as well
> (RFC1945, 10.6).  Also, thank you for adding this.

Modified patch below:

--- http.c.bak  2007-08-16 06:50:57.000000000 +0200
+++ http.c      2007-08-23 09:11:50.000000000 +0200
@@ -366,6 +366,20 @@ evhttp_make_header_response(struct evhtt
                        evhttp_add_header(req->output_headers,
                            "Content-Length", len);
                }
+
+               /* Add Date header. (Required by HTTP/1.1) */
+               char date[50];
+               struct tm cur;
+               time_t t = time(NULL);
+               int l;
+
+               gmtime_r(&t, &cur);
+               l = strftime(date, sizeof(date),
+                   "%a, %d %b %Y %H:%M:%S GMT", &cur);
+               if (l != 0) {
+                   evhttp_add_header(req->output_headers,
+                       "Date", date);
+               }
        }

        /* if the request asked for a close, we send a close, too */


-- 
Ralph Moritz
Ph: +27 84 626 9070
GPG Public Key: http://ralphm.info/public.gpg
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkey.org/mailman/listinfo/libevent-users

Reply via email to