From 30ff075889405111ca4ee96b424bedc315037158 2013-04-24 04:59:58 From: Min RK Date: 2013-04-24 04:59:58 Subject: [PATCH] Merge pull request #3181 from minrk/ifsince backport If-Modified-Since fix from tornado See facebook/tornado#713 closes #3177 --- diff --git a/IPython/frontend/html/notebook/handlers.py b/IPython/frontend/html/notebook/handlers.py index dd3eef4..d6536f8 100644 --- a/IPython/frontend/html/notebook/handlers.py +++ b/IPython/frontend/html/notebook/handlers.py @@ -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