backport If-Modified-Since fix from tornado

See facebook/tornado#713

closes #3177
This commit is contained in:
MinRK 2013-04-15 13:27:04 -07:00
parent 29b2d7ff95
commit 09913471e7

View File

@ -820,7 +820,7 @@ class FileFindHandler(web.StaticFileHandler):
raise HTTPError(403, "%s is not a file", path)
stat_result = os.stat(abspath)
modified = datetime.datetime.fromtimestamp(stat_result[stat.ST_MTIME])
modified = datetime.datetime.utcfromtimestamp(stat_result[stat.ST_MTIME])
self.set_header("Last-Modified", modified)
@ -844,7 +844,7 @@ class FileFindHandler(web.StaticFileHandler):
ims_value = self.request.headers.get("If-Modified-Since")
if ims_value is not None:
date_tuple = email.utils.parsedate(ims_value)
if_since = datetime.datetime.fromtimestamp(time.mktime(date_tuple))
if_since = datetime.datetime(*date_tuple[:6])
if if_since >= modified:
self.set_status(304)
return