Commit 49e287d2 authored by Julien Cristau's avatar Julien Cristau

tracker_service: send a Last-Modified header for /tracker/data/json

parent 9f257f26
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment