moved deafult headers logic, thanks Niphlod

This commit is contained in:
mdipierro committed 2012-09-11 17:32:46 -05:00
1 parent 6a170f3b7b
commit 91c0b6c76a
2 files changed
+17 -23

No files matched your search

+1 -1
View File
@@ -1 +1 @@
Version 2.0.8 (2012-09-11 16:49:24) stable Version 2.0.8 (2012-09-11 17:32:41) stable
+16 -22
View File
@@ -226,6 +226,20 @@ def serve_controller(request, response, session):
requests = ('requests' in globals()) and (requests+1) % 100 or 0 requests = ('requests' in globals()) and (requests+1) % 100 or 0
if not requests: gc.collect() if not requests: gc.collect()
# end garbage collection logic # end garbage collection logic
# ##################################################
# set default headers it not set
# ##################################################
default_headers = [
('Content-Type', contenttype('.'+request.extension)),
('Cache-Control','no-store, no-cache, must-revalidate, post-check=0, pre-check=0'),
('Expires', time.strftime('%a, %d %b %Y %H:%M:%S GMT',
time.gmtime())),
('Pragma', 'no-cache')]
for key,value in default_headers:
response.headers.setdefault(key,value)
raise HTTP(response.status, page, **response.headers) raise HTTP(response.status, page, **response.headers)
@@ -532,31 +546,11 @@ def wsgibase(environ, responder):
session._try_store_on_disk(request, response) session._try_store_on_disk(request, response)
# ##################################################
# set default headers it not set
# ##################################################
rheaders = http_response.headers
default_headers = [
('Content-Type', contenttype('.'+request.extension)),
('Cache-Control','no-store, no-cache, must-revalidate, post-check=0, pre-check=0'),
('Expires', time.strftime('%a, %d %b %Y %H:%M:%S GMT',
time.gmtime())),
('Pragma', 'no-cache')]
if request.cid: if request.cid:
if response.flash: if response.flash:
default_headers.append( http_response.headers['web2py-component-flash'] = urllib2.quote(xmlescape(response.flash).replace('\n',''))
('web2py-component-flash',
urllib2.quote(xmlescape(response.flash).replace('\n',''))))
if response.js: if response.js:
default_headers.append( http_response.headers['web2py-component-command'] = response.js.replace('\n','')
('web2py-component-command',
response.js.replace('\n','')))
for key,value in default_headers:
rheaders.setdefault(key,value)
# ################################################## # ##################################################
# store cookies in headers # store cookies in headers