Another tweak on the date patch: win32 has no gmtime_r, but its gmtime() function uses thread-local storage for safety. Backportable.

svn:r414
This commit is contained in:
Nick Mathewson 2007-09-07 01:18:53 +00:00
parent 003698c0df
commit 23866b7657

9
http.c
View File

@ -352,11 +352,16 @@ evhttp_make_header_response(struct evhttp_connection *evcon,
if (evhttp_find_header(req->output_headers,
"Date") == NULL) {
char date[50];
struct tm cur;
struct tm cur, *cur_p;
time_t t = time(NULL);
#ifdef WIN32
cur_p = gmtime(&t);
#else
gmtime_r(&t, &cur);
cur_p = &cur;
#endif
if (strftime(date, sizeof(date),
"%a, %d %b %Y %H:%M:%S GMT", &cur) != 0) {
"%a, %d %b %Y %H:%M:%S GMT", cur_p) != 0) {
evhttp_add_header(req->output_headers, "Date", date);
}
}