dart-archive / shelf_static

archived repo
https://github.com/dart-lang/shelf/tree/master/pkgs/shelf_static
BSD 3-Clause "New" or "Revised" License
24 stars 24 forks source link

Use file modified date for 304 checks ("changed" is creation date on Windows) #38

Closed DanTup closed 4 years ago

DanTup commented 4 years ago

This fixes #37 for me on Windows, however I don't know if there are any other consequences of changing this. The field named changed states in its dartdoc that on Windows is returns the creation date. Based on this SO answer it seems like on other platforms it returns the time of the last metadata change (whereas modified is file contents change).

If there's a reason to use changed for non-Windows platforms this could be made conditional (or perhaps just the latest of the two dates used?) - let me know if I should do that.

I added a test that catches this on Windows (it fails without the change, passes with), though the bots here don't run on Windows so currently wouldn't catch a regression. It also requires a small delay (2s) to ensure the timestamp changed - though if you're happy to check only the status code, it might be possible to drop that.

kevmoo commented 4 years ago

@DanTup care to update the version and changelog?

DanTup commented 4 years ago

Done!