Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Download updates DST error on Windows #2164

Closed
a0099 opened this issue Dec 7, 2017 · 5 comments
Closed

HTTP Download updates DST error on Windows #2164

a0099 opened this issue Dec 7, 2017 · 5 comments

Comments

@a0099
Copy link

a0099 commented Dec 7, 2017

I did this

Invoked curl.exe with -R and -z
The file on HTTP server was modified when DST was on (May 2017), now DST is off.
Repeated invocations caused download each time (200 OK) instead of 304 response after file was downloaded the first time.

I expected the following

If-Modified-Since in the get request to be the same as Last-Modified in HTTP response.
To calculate "If-Modified-Since" (GMT) curl used current time zone offset instead of the offset active at the time the file was last modified. "Last-Modified" (GMT) returned by MS IIS server was calculated correctly.
Also, Curl should keep and use full history of DST on/off dates for each time zone to handle DST for the files created years ago.

curl/libcurl version

curl 7.55.1 (i386-pc-win32) libcurl/7.55.1 zlib/1.2.8
Release-Date: 2017-08-14

operating system

Windows 2008 64bit

@bagder
Copy link
Member

bagder commented Dec 7, 2017

This sounds like the good old Windows being one hour off problems. curl stores the file normally (with what I believe is the correct timestamp from the remote server) and it uses the OS function calls to retrieve the time and date of the file in the subsequent request. If that then gets the wrong time due to DST or whatever, I don't think curl can do a whole lot about it. It uses the time the OS tells it.

the file was last modified. "Last-Modified" (GMT) returned by MS IIS server was calculated correctly

Which calculation was correct do you mean? Are you saying it set the correct file stamp on the saved file?

Curl should keep and use full history of DST on/off dates for each time zone to handle DST for the files created years ago.

No. curl asks the operating system for the file's timestamp.

@mkauf
Copy link
Contributor

mkauf commented Dec 12, 2017

This article proposes to use GetFileInformationByHandle() instead of stat() on Windows: http://search.cpan.org/~shay/Win32-UTCFileTime-1.58/lib/Win32/UTCFileTime.pm#BACKGROUND_REFERENCE

@mkauf
Copy link
Contributor

mkauf commented Dec 12, 2017

tool_operate.c contains the function setfiletime() with special code for Windows. It seems that we need a getfiletime() too.

As a "workaround", compile curl with a recent version of Visual C++, because stat() has been fixed in Visual C++ 2013: https://msdn.microsoft.com/en-us/library/bb531344.aspx

@bagder
Copy link
Member

bagder commented Dec 12, 2017

Oh, right, thanks for pointing that out. Now it all comes back to me.

For me personally I'm fine with recommending people with going >= MSVC 2013 (since they're available as no-cost downloads from Microsoft), but I also won't object if someone wants to go ahead and implement a getfiletime() function that works on other/earlier windows compilers.

mkauf added a commit to mkauf/curl that referenced this issue Dec 30, 2017
On Windows, stat() may adjust the unix file time by a daylight saving time
offset. Avoid this by calling GetFileTime() instead.

Fixes curl#2164
mkauf added a commit to mkauf/curl that referenced this issue Jan 31, 2018
On Windows, stat() may adjust the unix file time by a daylight saving time
offset. Avoid this by calling GetFileTime() instead.

Fixes curl#2164
@mkauf mkauf closed this as completed in d25b050 Feb 5, 2018
@mkauf mkauf removed the needs-info label Feb 5, 2018
@mkauf
Copy link
Contributor

mkauf commented Feb 5, 2018

Fixed, thanks for reporting!

@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants