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