Use file modified date for 304 checks ("changed" is creation date on Windows)
Fixes #37.
diff --git a/lib/src/static_handler.dart b/lib/src/static_handler.dart
index b6131ea..4f278ec 100644
--- a/lib/src/static_handler.dart
+++ b/lib/src/static_handler.dart
@@ -182,7 +182,7 @@
var ifModifiedSince = request.ifModifiedSince;
if (ifModifiedSince != null) {
- var fileChangeAtSecResolution = toSecondResolution(stat.changed);
+ var fileChangeAtSecResolution = toSecondResolution(stat.modified);
if (!fileChangeAtSecResolution.isAfter(ifModifiedSince)) {
return new Response.notModified();
}
@@ -190,7 +190,7 @@
var headers = {
HttpHeaders.contentLengthHeader: stat.size.toString(),
- HttpHeaders.lastModifiedHeader: formatHttpDate(stat.changed)
+ HttpHeaders.lastModifiedHeader: formatHttpDate(stat.modified)
};
var contentType = await getContentType();
diff --git a/test/basic_file_test.dart b/test/basic_file_test.dart
index 2b31dd6..bea7e16 100644
--- a/test/basic_file_test.dart
+++ b/test/basic_file_test.dart
@@ -86,7 +86,7 @@
var handler = createStaticHandler(d.sandbox);
var rootPath = p.join(d.sandbox, 'root.txt');
- var modified = new File(rootPath).statSync().changed.toUtc();
+ var modified = new File(rootPath).statSync().modified.toUtc();
var response = await makeRequest(handler, '/root.txt');
expect(response.lastModified, atSameTimeToSecond(modified));
@@ -97,7 +97,7 @@
var handler = createStaticHandler(d.sandbox);
var rootPath = p.join(d.sandbox, 'root.txt');
- var modified = new File(rootPath).statSync().changed.toUtc();
+ var modified = new File(rootPath).statSync().modified.toUtc();
var headers = {
HttpHeaders.ifModifiedSinceHeader: formatHttpDate(modified)
@@ -112,7 +112,7 @@
var handler = createStaticHandler(d.sandbox);
var rootPath = p.join(d.sandbox, 'root.txt');
- var modified = new File(rootPath).statSync().changed.toUtc();
+ var modified = new File(rootPath).statSync().modified.toUtc();
var headers = {
HttpHeaders.ifModifiedSinceHeader:
@@ -128,7 +128,7 @@
var handler = createStaticHandler(d.sandbox);
var rootPath = p.join(d.sandbox, 'root.txt');
- var modified = new File(rootPath).statSync().changed.toUtc();
+ var modified = new File(rootPath).statSync().modified.toUtc();
var headers = {
HttpHeaders.ifModifiedSinceHeader:
diff --git a/test/sample_test.dart b/test/sample_test.dart
index 1c4b85f..87d2486 100644
--- a/test/sample_test.dart
+++ b/test/sample_test.dart
@@ -62,7 +62,7 @@
var response = await _requestFile(filename);
expect(response.contentLength, fileStat.size);
- expect(response.lastModified, atSameTimeToSecond(fileStat.changed.toUtc()));
+ expect(response.lastModified, atSameTimeToSecond(fileStat.modified.toUtc()));
await _expectCompletesWithBytes(response, fileContents);
}