From eff4c5e7ec361968294c825a842b7d065d5d0c59 Mon Sep 17 00:00:00 2001 From: David Wolever Date: Wed, 29 May 2013 14:37:51 -0400 Subject: [PATCH] Return a valid Content-Range header --- tornado/httputil.py | 8 ++++---- tornado/test/web_test.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tornado/httputil.py b/tornado/httputil.py index 36ac61063..04a0977b1 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -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): diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index e7735a056..5f459a81f 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -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={ -- 2.47.2