]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Return a valid Content-Range header 806/head
authorDavid Wolever <david@wolever.net>
Wed, 29 May 2013 18:37:51 +0000 (14:37 -0400)
committerDavid Wolever <david@wolever.net>
Wed, 29 May 2013 18:37:51 +0000 (14:37 -0400)
tornado/httputil.py
tornado/test/web_test.py

index 36ac61063bfa3e98a61ea049f3bc5c93cd6a9256..04a0977b1a4d822615a61d6a05a0a30ffa54cc2a 100644 (file)
@@ -289,15 +289,15 @@ def _get_content_range(start, end, total):
     """Returns a suitable Content-Range header:
 
     >>> print(_get_content_range(None, 1, 4))
-    0-0/4
+    bytes 0-0/4
     >>> print(_get_content_range(1, 3, 4))
-    1-2/4
+    bytes 1-2/4
     >>> print(_get_content_range(None, None, 4))
-    0-3/4
+    bytes 0-3/4
     """
     start = start or 0
     end = (end or total) - 1
-    return "%s-%s/%s" % (start, end, total)
+    return "bytes %s-%s/%s" % (start, end, total)
 
 
 def _int_or_none(val):
index e7735a05638b4700554b6757f47e31116e53a9d4..5f459a81f168fad351374b99856198bd158133f5 100644 (file)
@@ -886,7 +886,7 @@ class StaticFileTest(WebTestCase):
                          b'"' + self.robots_txt_hash + b'"')
         self.assertEqual(response.headers.get("Content-Length"), "10")
         self.assertEqual(response.headers.get("Content-Range"),
-                         "0-9/26")
+                         "bytes 0-9/26")
 
     def test_static_with_range_full_file(self):
         response = self.fetch('/static/robots.txt', headers={
@@ -906,7 +906,7 @@ class StaticFileTest(WebTestCase):
         self.assertEqual(response.body, b": /\n")
         self.assertEqual(response.headers.get("Content-Length"), "4")
         self.assertEqual(response.headers.get("Content-Range"),
-                         "22-25/26")
+                         "bytes 22-25/26")
 
     def test_static_with_range_neg_end(self):
         response = self.fetch('/static/robots.txt', headers={
@@ -914,7 +914,7 @@ class StaticFileTest(WebTestCase):
         self.assertEqual(response.body, b": /\n")
         self.assertEqual(response.headers.get("Content-Length"), "4")
         self.assertEqual(response.headers.get("Content-Range"),
-                         "22-25/26")
+                         "bytes 22-25/26")
 
     def test_static_invalid_range(self):
         response = self.fetch('/static/robots.txt', headers={