1. cherrypy
  2. CherryPy

Commits

Robert Brewer  committed d7336b5

New tests for multiple response header values.

  • Participants
  • Parent commits 1befc74
  • Branches default

Comments (0)

Files changed (1)

File py2/cherrypy/test/test_core.py

View file
                     cherrypy.response.cookie[str(name)] = cookie.value
 
 
+        def append_headers(header_list, debug=False):
+            if debug:
+                cherrypy.log(
+                    "Extending response headers with %s" % repr(header_list),
+                    "TOOLS.APPEND_HEADERS")
+            cherrypy.serving.response.header_list.extend(header_list)
+        cherrypy.tools.append_headers = cherrypy.Tool('on_end_resource', append_headers)
+        
+        class MultiHeader(Test):
+            
+            @cherrypy.tools.append_headers(header_list=[
+                ('WWW-Authenticate', 'Negotiate'),
+                ('WWW-Authenticate', 'Basic realm="foo"'),
+                ])
+            def header_list(self):
+                pass
+            
+            def commas(self):
+                cherrypy.response.headers['WWW-Authenticate'] = 'Negotiate,Basic realm="foo"'
+
+
         cherrypy.tree.mount(root)
     setup_server = staticmethod(setup_server)
 
         self.assertHeader('Content-Type', 'text/plain;charset=utf-8')
         self.getPage('/defct/html')
     
+    def test_multiple_headers(self):
+        self.getPage('/multiheader/header_list')
+        self.assertEqual([(k, v) for k, v in self.headers if k == 'WWW-Authenticate'],
+                         [('WWW-Authenticate', 'Negotiate'),
+                          ('WWW-Authenticate', 'Basic realm="foo"'),
+                          ])
+        self.getPage('/multiheader/commas')
+        self.assertHeader('WWW-Authenticate', 'Negotiate,Basic realm="foo"')
+    
     def test_cherrypy_url(self):
         # Input relative to current
         self.getPage('/url/leaf?path_info=page1')