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
This commit is contained in:
Clark Boylan 2014-06-03 21:22:40 -07:00
parent 9601f6463c
commit aa4f2e7a3a
2 changed files with 7 additions and 0 deletions

View File

@ -1937,6 +1937,12 @@ class TestScheduler(ZuulTestCase):
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

View File

@ -57,4 +57,5 @@ class WebApp(threading.Thread):
response = webob.Response(body=self.cache,
content_type='application/json')
response.headers['Access-Control-Allow-Origin'] = '*'
response.last_modified = self.cache_time
return response