Don't send 304s for avatars or media

main
Bob Mottram 2021-09-26 15:13:28 +01:00
parent 5211451693
commit bf433e34f0
1 changed files with 15 additions and 12 deletions

View File

@ -6486,10 +6486,11 @@ class PubServer(BaseHTTPRequestHandler):
mediaStr = path.split('/media/')[1]
mediaFilename = baseDir + '/media/' + mediaStr
if os.path.isfile(mediaFilename):
if self._etag_exists(mediaFilename):
# The file has not changed
self._304()
return
# TEST
#if self._etag_exists(mediaFilename):
# # The file has not changed
# self._304()
# return
mediaFileType = mediaFileMimeType(mediaFilename)
@ -6685,10 +6686,11 @@ class PubServer(BaseHTTPRequestHandler):
"""
mediaFilename = baseDir + '/cache' + path
if os.path.isfile(mediaFilename):
if self._etag_exists(mediaFilename):
# The file has not changed
self._304()
return
# TEST
# if self._etag_exists(mediaFilename):
# # The file has not changed
# self._304()
# return
with open(mediaFilename, 'rb') as avFile:
mediaBinary = avFile.read()
mimeType = mediaFileMimeType(mediaFilename)
@ -11367,10 +11369,11 @@ class PubServer(BaseHTTPRequestHandler):
acctDir(baseDir, avatarNickname, domain) + '/' + avatarFile
if not os.path.isfile(avatarFilename):
return False
if self._etag_exists(avatarFilename):
# The file has not changed
self._304()
return True
# TEST
# if self._etag_exists(avatarFilename):
# # The file has not changed
# self._304()
# return True
t = os.path.getmtime(avatarFilename)
lastModifiedTime = datetime.datetime.fromtimestamp(t)