Robert Brewer avatar Robert Brewer committed e8591b0

Backport of [2013] to branches/3.1.x.

Comments (0)

Files changed (2)


 _d.log_headers = Tool('before_error_response', cptools.log_request_headers)
 _d.log_hooks = Tool('on_end_request', cptools.log_hooks, priority=100)
 _d.err_redirect = ErrorTool(cptools.redirect)
-_d.etags = Tool('before_finalize', cptools.validate_etags)
+_d.etags = Tool('before_finalize', cptools.validate_etags, priority=75)
 _d.decode = Tool('before_handler', encoding.decode)
 # the order of encoding, gzip, caching is important
 _d.encode = Tool('before_finalize', encoding.encode, priority=70)


                 raise cherrypy.HTTPError(code) = True
+        def unicoded(self):
+            return u'I am a \u1ee4nicode string.'
+ = True
+        unicoded._cp_config = {'tools.encode.on': True}
     conf = {'/': {'tools.etags.on': True,
-                  'tools.etags.autotags': True}}
+                  'tools.etags.autotags': True,
+                  }}
     cherrypy.tree.mount(Root(), config=conf)
     cherrypy.config.update({'environment': 'test_suite'})
 class ETagTest(helper.CPWebCase):
-    def testETags(self):
+    def test_etags(self):
         self.assertStatus('200 OK')
         self.assertHeader('Content-Type', 'text/html')
         self.getPage("/resource", headers=[('If-None-Match', "a bogus tag")])
         self.assertStatus("200 OK")
+    def test_errors(self):
+        self.getPage("/resource")
+        self.assertStatus(200)
+        etag = self.assertHeader('ETag')
         # Test raising errors in page handler
         self.getPage("/fail/412", headers=[('If-Match', etag)])
         self.getPage("/fail/304", headers=[('If-None-Match', "*")])
+    def test_unicode_body(self):
+        self.getPage("/unicoded")
+        self.assertStatus(200)
+        etag1 = self.assertHeader('ETag')
+        self.getPage("/unicoded", headers=[('If-Match', etag1)])
+        self.assertStatus(200)
+        self.assertHeader('ETag', etag1)
 if __name__ == "__main__":
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
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.