curl-library
Re: [ curl-Patches-831843 ] Add --head support for file: protocol
Date: Wed, 29 Oct 2003 10:02:22 -0800
Daniel Stenberg writes:
> On Tue, 28 Oct 2003, SourceForge.net wrote:
>
> > https://sourceforge.net/tracker/?func=detail&atid=300976&aid=831843&group_id=976
>
> While applying and fiddling with your patch here, it struck me that
> localtime() might not be the correct function to use since it
> attempts to return the date using GMT? Isn't gmtime (and gmtime_r)
> a better option here?
>
> I realize this code was copied from lib/ftp.c and the problem might
> exist there too, but in the case of FTP the time zone given by the
> server is not known!
You're right; I was asleep at the wheel. The code in question from my
patch to file.c is:
#ifdef HAVE_LOCALTIME_R
struct tm buffer;
tm = (struct tm *)localtime_r((time_t *)&data->info.filetime, &buffer);
#else
tm = localtime((time_t *)&data->info.filetime);
#endif
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
strftime(buf, BUFSIZE-1,"Last-Modified: %a, %d %b %Y %H:%M:%S GMT\r\n",
tm);
and as you see the strftime prints "GMT" as the time zone. The call
to localtime/localtime_r should be to gmtime/gmtime_r. The same
change needs to be made in ftp.c.
-- David Hull ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/Received on 2003-10-29