Set Last-Modified header when serving status.json
Apache won't cache anything without a Last-Modified header. Be a good
citizen and set the Last-Modified header when serving status.json data.
Set the value to the cache_time timestamp.
Update the status checking test to make sure that this and other headers
are properly present so that this does not regress.
Change-Id: I2215d9c9694bd9ef7b94f29f654da77ae85a9959
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index c696bab..7b99056 100755
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -1937,6 +1937,12 @@
req = urllib2.Request("http://localhost:%s/status.json" % port)
f = urllib2.urlopen(req)
+ headers = f.info()
+ self.assertIn('Content-Length', headers)
+ self.assertIn('Content-Type', headers)
+ self.assertEqual(headers['Content-Type'],
+ 'application/json; charset=UTF-8')
+ self.assertIn('Last-Modified', headers)
data = f.read()
self.worker.hold_jobs_in_build = False
diff --git a/zuul/webapp.py b/zuul/webapp.py
index fc52e07..4d6115f 100644
--- a/zuul/webapp.py
+++ b/zuul/webapp.py
@@ -57,4 +57,5 @@
response = webob.Response(body=self.cache,
content_type='application/json')
response.headers['Access-Control-Allow-Origin'] = '*'
+ response.last_modified = self.cache_time
return response