From 9c2292edbe6ae0e9258236937eb35b11b0b993b3 Mon Sep 17 00:00:00 2001 From: "zengyun261@qq.com" Date: Mon, 27 Mar 2017 20:59:02 +0800 Subject: [PATCH] fix IF_MODIFIED_SINCE --- lib/src/cache.dart | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/src/cache.dart b/lib/src/cache.dart index e28ed664..db310efe 100644 --- a/lib/src/cache.dart +++ b/lib/src/cache.dart @@ -120,12 +120,9 @@ class CachingVirtualDirectory extends VirtualDirectory { if (req.headers[HttpHeaders.IF_MODIFIED_SINCE] != null) { try { - var ifModifiedSince = _fmt.parse(req.headers - .value(HttpHeaders.IF_MODIFIED_SINCE) - .replaceAll('GMT', '') - .trim()); + var ifModifiedSince = req.headers.ifModifiedSince; - if (ifModifiedSince.compareTo(stat.changed) > 0) { + if (ifModifiedSince.compareTo(stat.modified) >= 0) { res.statusCode = HttpStatus.NOT_MODIFIED; setCachedHeaders(file, stat, req, res); @@ -170,7 +167,7 @@ class CachingVirtualDirectory extends VirtualDirectory { res.headers ..[HttpHeaders.CACHE_CONTROL] = '$privacy, max-age=${maxAge ?? 0}' ..[HttpHeaders.EXPIRES] = formatDateForHttp(expiry) - ..[HttpHeaders.LAST_MODIFIED] = formatDateForHttp(stat.changed); + ..[HttpHeaders.LAST_MODIFIED] = formatDateForHttp(stat.modified); } }