Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

root/branches/cherrypy-2.x/cherrypy/filters/responseheadersfilter.py

Revision 860 (checked in by lawouach, 3 years ago)

added the response_headers_filter and headers decorator to fix ticket 302

Line 
1 import cherrypy
2 from basefilter import BaseFilter
3
4 class ResponseHeadersFilter(BaseFilter):
5     """Filter that allows HTTP headers to be defined for all responses"""
6
7     def before_finalize(self):
8         conf = cherrypy.config.get
9         if not conf('response_headers_filter.on', False):
10             return
11
12         # headers must be a list of tuples
13         headers = conf('response_headers_filter.headers', [])
14
15         for item in headers:
16             headername = item[0]
17             headervalue = item[1]
18             if headername not in cherrypy.response.headerMap:
19                 cherrypy.response.headerMap[headername] = headervalue
Note: See TracBrowser for help on using the browser.

Hosted by WebFaction

Log in as guest/cpguest to create tickets