Changeset 1051
- Timestamp:
- 04/21/06 16:42:11
- Files:
-
- trunk/cherrypy/lib/cptools.py (modified) (1 diff)
- trunk/cherrypy/test/test_response_headers_filter.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/cptools.py
r1049 r1051 205 205 206 206 207 def response_headers(headers=None ):207 def response_headers(headers=None, force=True): 208 208 """Set headers on the response.""" 209 for name, value in headers or []:210 if name not in cherrypy.response.headers:209 for name, value in (headers or []): 210 if force or (name not in cherrypy.response.headers): 211 211 cherrypy.response.headers[name] = value 212 212 trunk/cherrypy/test/test_response_headers_filter.py
r1049 r1051 23 23 '/other': { 24 24 'tools.response_headers.on': True, 25 'tools.response_headers.force': False, 25 26 'tools.response_headers.headers': [("Content-Language", "fr"), 26 ('Content-Type', 'text/plain')] 27 ('Content-Type', 'text/plain')], 27 28 }, 28 29 }) … … 41 42 self.getPage('/other') 42 43 self.assertHeader("Content-Language", "fr") 43 # the filter should only change headers that have not been set yet 44 # Since 'force' is False, the filter should only change headers 45 # that have not been set yet. 44 46 # Content-Type should have been set when the response object 45 47 # was created (default to text/html)

