fix IF_MODIFIED_SINCE

This commit is contained in:
zengyun261@qq.com 2017-03-27 20:59:02 +08:00
parent 7230a932c0
commit 9c2292edbe

View file

@ -120,12 +120,9 @@ class CachingVirtualDirectory extends VirtualDirectory {
if (req.headers[HttpHeaders.IF_MODIFIED_SINCE] != null) { if (req.headers[HttpHeaders.IF_MODIFIED_SINCE] != null) {
try { try {
var ifModifiedSince = _fmt.parse(req.headers var ifModifiedSince = req.headers.ifModifiedSince;
.value(HttpHeaders.IF_MODIFIED_SINCE)
.replaceAll('GMT', '')
.trim());
if (ifModifiedSince.compareTo(stat.changed) > 0) { if (ifModifiedSince.compareTo(stat.modified) >= 0) {
res.statusCode = HttpStatus.NOT_MODIFIED; res.statusCode = HttpStatus.NOT_MODIFIED;
setCachedHeaders(file, stat, req, res); setCachedHeaders(file, stat, req, res);
@ -170,7 +167,7 @@ class CachingVirtualDirectory extends VirtualDirectory {
res.headers res.headers
..[HttpHeaders.CACHE_CONTROL] = '$privacy, max-age=${maxAge ?? 0}' ..[HttpHeaders.CACHE_CONTROL] = '$privacy, max-age=${maxAge ?? 0}'
..[HttpHeaders.EXPIRES] = formatDateForHttp(expiry) ..[HttpHeaders.EXPIRES] = formatDateForHttp(expiry)
..[HttpHeaders.LAST_MODIFIED] = formatDateForHttp(stat.changed); ..[HttpHeaders.LAST_MODIFIED] = formatDateForHttp(stat.modified);
} }
} }