Commits

Anonymous committed 4979aa2

Added test capturing failure when headers and cookies have unicode aspects to them

Comments (0)

Files changed (1)

cherrypy/test/test_encoding.py

+#-*- coding: utf-8 -*-
 from cherrypy.test import test
 test.prefer_parent_path()
 
             return sing8
         utf8.exposed = True
         utf8._cp_config = {'tools.encode.encoding': 'utf-8'}
-    
+
+        def cookies_and_headers(self):
+            # if the headers have non-ascii characters and a cookie has
+            #  any part which is unicode (even ascii), the response
+            #  should not fail.
+            cherrypy.response.cookie['candy'] = 'bar'
+            cherrypy.response.cookie['candy']['domain'] = u'cherrypy.org'
+            cherrypy.response.headers['Some-Header'] = u'My dög has fleas'
+            return 'Any content'
+        cookies_and_headers.exposed = True
+
     class GZIP:
         def index(self):
             yield "Hello, world"
         self.assertHeader('Content-Encoding', 'gzip')
         self.assertMatchesBody(r"Unrecoverable error in the server.$")
 
+    def test_UnicodeHeaders(self):
+        self.getPage('/cookies_and_headers')
+        self.assertBody('Any content')
+
 
 if __name__ == "__main__":
     setup_server()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.