From: David Wolever Date: Tue, 21 May 2013 04:47:15 +0000 (-0400) Subject: Only send Content-Range with HTTP 206 X-Git-Tag: v3.1.0~56^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F794%2Fhead;p=thirdparty%2Ftornado.git Only send Content-Range with HTTP 206 --- diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 65417f9a8..018004baf 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -896,7 +896,7 @@ class StaticFileTest(WebTestCase): with open(robots_file_path) as f: self.assertEqual(response.body, utf8(f.read())) self.assertEqual(response.headers.get("Content-Length"), "26") - self.assertEqual(response.headers.get("Content-Range"), "0-25/26") + self.assertEqual(response.headers.get("Content-Range"), None) def test_static_with_range_end_edge(self): response = self.fetch('/static/robots.txt', headers={ diff --git a/tornado/web.py b/tornado/web.py index bbf68d05c..1d5dea217 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -1816,8 +1816,8 @@ class StaticFileHandler(RequestHandler): # ``Range: bytes=0-``. if size != (end or size) - (start or 0): self.set_status(206) # Partial Content - self.set_header("Content-Range", - httputil._get_content_range(start, end, size)) + self.set_header("Content-Range", + httputil._get_content_range(start, end, size)) else: start = end = None content = self.get_content(self.absolute_path, start, end)