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.
On 8/22/07, Chris Ross <[EMAIL PROTECTED]> wrote:If you're building a Date header anyway, why not go ahead and do it in the case of 100 and 101, as well? It says it's permitted, simply not required, so I don't see any significant value in special- casing those two response codes... - Chris On Aug 22, 2007, at 12:51, Ralph Moritz wrote:Hi, according to RFC 2616: Origin servers MUST include a Date header field in all responses, except in these cases: 1. If the response status code is 100 (Continue) or 101 (Switching Protocols), the response MAY include a Date header field, at the server's option. 2. If the response status code conveys a server error, e.g. 500 (Internal Server Error) or 503 (Service Unavailable), and it is inconvenient or impossible to generate a valid Date. 3. If the server does not have a clock that can provide a reasonable approximation of the current time, its responses MUST NOT include a Date header field. In this case, the rules in section 14.18.1 MUST be followed. So I've modified `evhttp_make_header_response' appropriately. Patch below: --- http.c.bak 2007-08-16 06:50:57.000000000 +0200 +++ http.c 2007-08-22 18:48:42.000000000 +0200 @@ -366,6 +366,25 @@ evhttp_make_header_response(struct evhtt evhttp_add_header(req->output_headers, "Content-Length", len); } + + /* + * Add required Date header to HTTP/1.1 responses. + * (Except those with status 100/1) + */ + if ((req->major == 1) + && (req->minor == 1) + && (req->response_code != 100) + && (req->response_code != 101)) { + static char date[50]; + static struct tm cur; + time_t t = time(NULL); + + gmtime_r(&t, &cur); + strftime(date, sizeof(date), + "%a, %d %b %Y %H:%M:%S GMT", &cur); + 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 [email protected] http://monkey.org/mailman/listinfo/libevent-users
_______________________________________________ Libevent-users mailing list [email protected] http://monkey.org/mailman/listinfo/libevent-users
