Return code if file has not changed

main
Bob Mottram 2019-12-04 13:05:12 +00:00
parent 1c2a643522
commit c1f098db8f
1 changed files with 5 additions and 3 deletions

View File

@ -438,6 +438,9 @@ class PubServer(BaseHTTPRequestHandler):
def _404(self) -> None:
self._httpReturnCode(404,'Not Found')
def _304(self) -> None:
self._httpReturnCode(304,'Resource has not changed')
def _400(self) -> None:
self._httpReturnCode(400,'Bad Request')
@ -1431,9 +1434,8 @@ class PubServer(BaseHTTPRequestHandler):
except:
pass
if oldEtag==currEtag:
# if the etags are the same then only return the header
# not the media
self._set_headers(mediaFileType,mediaBinary,cookie)
# The file has not changed
self._304()
return
with open(mediaFilename, 'rb') as avFile:
mediaBinary = avFile.read()