summaryrefslogtreecommitdiffstats
path: root/bin/tracker_service.py
diff options
context:
space:
mode:
authorJulien Cristau <jcristau@debian.org>2018-07-06 11:58:52 +0200
committerJulien Cristau <jcristau@debian.org>2018-07-06 14:02:13 +0200
commit49e287d2574ed385e31ce3d36cb3cb19f4c7785f (patch)
tree40cef745a896bd2f2d328800cf0aaea0bcbde169 /bin/tracker_service.py
parent9f257f267491b72766688191b654d12b04670f24 (diff)
tracker_service: send a Last-Modified header for /tracker/data/json
Diffstat (limited to 'bin/tracker_service.py')
-rwxr-xr-xbin/tracker_service.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/bin/tracker_service.py b/bin/tracker_service.py
index 8757d0c4da..7e89c65632 100755
--- a/bin/tracker_service.py
+++ b/bin/tracker_service.py
@@ -1298,7 +1298,7 @@ Debian bug number.'''),
self.json_generation_interval seconds ago """
if self.json_timestamp: # we've generated the JSON at least once
- delta = datetime.now() - self.json_timestamp
+ delta = datetime.utcnow() - self.json_timestamp
if delta.total_seconds() <= self.json_generation_interval:
# not expired yet, serve the cached data
return self.json_data
@@ -1450,15 +1450,16 @@ Debian bug number.'''),
# store the JSON dump in memory, and update the generation
# timestamp before returning
- self.json_data = json.dumps(data, separators=(',', ':'))
- self.json_timestamp = datetime.now()
+ new_data = json.dumps(data, separators=(',', ':'))
+ if new_data != self.json_data:
+ self.json_data = new_data
+ self.json_timestamp = datetime.utcnow()
return self.json_data
def page_json(self, path, params, url):
- # FIXME: we want to send along a Last-Modified header, whose
- # value will be:
- # self.json_timestamp.strftime("%a, %d %b %Y %H:%M:%S ") + TZ
- return BinaryResult(self._get_json(),'application/octet-stream')
+ result = BinaryResult(self._get_json(),'application/octet-stream')
+ result.headers['Last-Modified'] = self.json_timestamp.strftime("%a, %d %b %Y %H:%M:%S GMT")
+ return result
def page_debsecan(self, path, params, url):
obj = '/'.join(path)

© 2014-2024 Faster IT GmbH | imprint | privacy policy