]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
fixed bytes error in `check_etag_header` so that it can run in python3
authordaftshady <daftonshady@gmail.com>
Thu, 5 Mar 2015 08:58:55 +0000 (17:58 +0900)
committerdaftshady <daftonshady@gmail.com>
Thu, 5 Mar 2015 08:58:55 +0000 (17:58 +0900)
tornado/web.py

index df6436247481a8abf6fc65355dcac12b3e338170..f4e8a84aa063e947e9cc05cd74a25763f62ae56c 100644 (file)
@@ -1310,22 +1310,22 @@ class RequestHandler(object):
         before completing the request.  The ``Etag`` header should be set
         (perhaps with `set_etag_header`) before calling this method.
         """
-        computed_etag = self._headers.get("Etag")
+        computed_etag = utf8(self._headers.get("Etag", ""))
         # Find all weak and strong etag values from If-None-Match header
         # because RFC 7232 allows multiple etag values in a single header.
         etags = re.findall(
-            r'\*|(?:W/)?"[^"]*"',
+            br'\*|(?:W/)?"[^"]*"',
             utf8(self.request.headers.get("If-None-Match", ""))
         )
         if not computed_etag or not etags:
             return False
 
         match = False
-        if etags[0] == '*':
+        if etags[0] == b'*':
             match = True
         else:
             # Use a weak comparison when comparing entity-tags.
-            val = lambda x: x[2:] if x.startswith('W/') else x
+            val = lambda x: x[2:] if x.startswith(b'W/') else x
             for etag in etags:
                 if val(etag) == val(computed_etag):
                     match = True