if not os.path.isfile(abspath):
raise HTTPError(403, "%s is not a file", path)
- # Check the If-Modified-Since, and don't send the result if the
- # content has not been modified
stat_result = os.stat(abspath)
modified = datetime.datetime.fromtimestamp(stat_result[stat.ST_MTIME])
- 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 if_since >= modified:
- self.set_status(304)
- return
self.set_header("Last-Modified", modified)
self.set_header("Content-Length", stat_result[stat.ST_SIZE])
if mime_type:
self.set_header("Content-Type", mime_type)
+ # Check the If-Modified-Since, and don't send the result if the
+ # content has not been modified
+ 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 if_since >= modified:
+ self.set_status(304)
+ return
+
if not include_body:
return
file = open(abspath, "r")