This also sets the access time to the same value, but we're only
calling _get_file if we're about to serve the file to a client, which
will clobber any value of atime set here.
+import calendar as _calendar
import email.utils as _email_utils
import mimetypes as _mimetypes
import os as _os
import email.utils as _email_utils
import mimetypes as _mimetypes
import os as _os
def _get_file(self, url, path):
with self.opener.open(url) as response:
def _get_file(self, url, path):
with self.opener.open(url) as response:
+ last_modified = response.getheader('Last-Modified', None)
content_length = int(response.getheader('Content-Length'))
with open(path, 'wb') as f:
block_size = 8192
content_length = int(response.getheader('Content-Length'))
with open(path, 'wb') as f:
block_size = 8192
f.write(data)
if len(data) < block_size:
break
f.write(data)
if len(data) < block_size:
break
+ if last_modified:
+ mtime = _calendar.timegm(_email_utils.parsedate(last_modified))
+ _os.utime(path=path, times=(mtime, mtime))
def _serve_file(self, path, environ, start_response):
headers = {
def _serve_file(self, path, environ, start_response):
headers = {