mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
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:
parent
003698c0df
commit
23866b7657
9
http.c
9
http.c
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user