Merge "Correct Last-Modified header for status API"

This commit is contained in:
Zuul 2018-09-13 23:27:52 +00:00 committed by Gerrit Code Review
commit 0ff807b2f6
2 changed files with 5 additions and 1 deletions

View File

@ -109,6 +109,7 @@ class TestWeb(BaseTestWeb):
self.assertIn('Access-Control-Allow-Origin', resp.headers)
self.assertIn('Cache-Control', resp.headers)
self.assertIn('Last-Modified', resp.headers)
self.assertTrue(resp.headers['Last-Modified'].endswith(' GMT'))
self.executor_server.hold_jobs_in_build = False
self.executor_server.release()

View File

@ -21,6 +21,7 @@ from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool
from ws4py.websocket import WebSocket
import codecs
import copy
from datetime import datetime
import json
import logging
import os
@ -245,7 +246,9 @@ class ZuulWebAPI(object):
resp = cherrypy.response
resp.headers["Cache-Control"] = "public, max-age=%d" % \
self.cache_expiry
resp.headers["Last-modified"] = self.cache_time[tenant]
last_modified = datetime.utcfromtimestamp(self.cache_time[tenant])
last_modified_header = last_modified.strftime('%a, %d %b %Y %X GMT')
resp.headers["Last-modified"] = last_modified_header
resp.headers['Access-Control-Allow-Origin'] = '*'
return payload