Use etags on images

main
Bob Mottram 2020-04-13 20:28:35 +01:00
parent 6009193a66
commit 1c66f2fde7
1 changed files with 14 additions and 9 deletions

View File

@ -1440,8 +1440,10 @@ class PubServer(BaseHTTPRequestHandler):
time.sleep(1) time.sleep(1)
tries += 1 tries += 1
if mediaBinary: if mediaBinary:
self._set_headers('image/png', len(mediaBinary), self._set_headers_etag(mediaFilename,
cookie, callingDomain) 'image/png',
mediaBinary, cookie,
callingDomain)
self._write(mediaBinary) self._write(mediaBinary)
return return
self._404() self._404()
@ -1466,8 +1468,9 @@ class PubServer(BaseHTTPRequestHandler):
time.sleep(1) time.sleep(1)
tries += 1 tries += 1
if mediaBinary: if mediaBinary:
self._set_headers('image/png', len(mediaBinary), self._set_headers_etag(mediaFilename, 'image/png',
cookie, callingDomain) mediaBinary, cookie,
callingDomain)
self._write(mediaBinary) self._write(mediaBinary)
return return
self._404() self._404()
@ -1492,8 +1495,9 @@ class PubServer(BaseHTTPRequestHandler):
time.sleep(1) time.sleep(1)
tries += 1 tries += 1
if mediaBinary: if mediaBinary:
self._set_headers('image/png', len(mediaBinary), self._set_headers_etag(mediaFilename, 'image/png',
cookie, callingDomain) mediaBinary, cookie,
callingDomain)
self._write(mediaBinary) self._write(mediaBinary)
return return
self._404() self._404()
@ -1521,9 +1525,10 @@ class PubServer(BaseHTTPRequestHandler):
mediaImageType = 'gif' mediaImageType = 'gif'
with open(emojiFilename, 'rb') as avFile: with open(emojiFilename, 'rb') as avFile:
mediaBinary = avFile.read() mediaBinary = avFile.read()
self._set_headers('image/' + mediaImageType, self._set_headers_etag(emojiFilename,
len(mediaBinary), 'image/' + mediaImageType,
cookie, callingDomain) mediaBinary, cookie,
callingDomain)
self._write(mediaBinary) self._write(mediaBinary)
return return
self._404() self._404()