mirror of https://gitlab.com/bashrc2/epicyon
Include last modified time in HEAD
parent
225f9d9270
commit
5dd2910e11
16
daemon.py
16
daemon.py
|
@ -871,11 +871,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.end_headers()
|
||||
|
||||
def _set_headers_head(self, file_format: str, length: int, etag: str,
|
||||
calling_domain: str, permissive: bool) -> None:
|
||||
calling_domain: str, permissive: bool,
|
||||
last_modified_time_str: str) -> None:
|
||||
self._set_headers_base(file_format, length, None, calling_domain,
|
||||
permissive)
|
||||
if etag:
|
||||
self.send_header('ETag', '"' + etag + '"')
|
||||
if last_modified_time_str:
|
||||
self.send_header('last-modified',
|
||||
last_modified_time_str)
|
||||
self.end_headers()
|
||||
|
||||
def _set_headers_etag(self, media_filename: str, file_format: str,
|
||||
|
@ -18597,6 +18601,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
check_path = self.path
|
||||
etag = None
|
||||
file_length = -1
|
||||
last_modified_time_str = None
|
||||
|
||||
if '/media/' in self.path or \
|
||||
'/accounts/avatars/' in self.path or \
|
||||
|
@ -18642,6 +18647,12 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if os.path.isfile(media_filename):
|
||||
check_path = media_filename
|
||||
file_length = os.path.getsize(media_filename)
|
||||
media_tm = os.path.getmtime(media_filename)
|
||||
last_modified_time = \
|
||||
datetime.datetime.fromtimestamp(media_tm)
|
||||
time_format_str = '%a, %d %b %Y %H:%M:%S GMT'
|
||||
last_modified_time_str = \
|
||||
last_modified_time.strftime(time_format_str)
|
||||
media_tag_filename = media_filename + '.etag'
|
||||
if os.path.isfile(media_tag_filename):
|
||||
try:
|
||||
|
@ -18672,7 +18683,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
|
||||
media_file_type = media_file_mime_type(check_path)
|
||||
self._set_headers_head(media_file_type, file_length,
|
||||
etag, calling_domain, False)
|
||||
etag, calling_domain, False,
|
||||
last_modified_time_str)
|
||||
|
||||
def _receive_new_post_process(self, post_type: str, path: str, headers: {},
|
||||
length: int, post_bytes, boundary: str,
|
||||
|
|
Loading…
Reference in New Issue