From c1f098db8fcbdd7a7998522b9ed92f3174be8644 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 4 Dec 2019 13:05:12 +0000 Subject: [PATCH] Return code if file has not changed --- daemon.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/daemon.py b/daemon.py index 56c18cf4..dfff1539 100644 --- a/daemon.py +++ b/daemon.py @@ -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()