From: David Wolever Date: Sat, 18 May 2013 19:30:41 +0000 (-0400) Subject: Return HTTP 416 Range Not Satisfiable, not 406 X-Git-Tag: v3.1.0~68^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=907216eaf988a9bcc70888077d4d25a9e7b746bc;p=thirdparty%2Ftornado.git Return HTTP 416 Range Not Satisfiable, not 406 --- diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 09f04ae6e..751cde929 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -897,7 +897,7 @@ class StaticFileTest(WebTestCase): def test_static_invalid_range(self): response = self.fetch('/static/robots.txt', headers={ 'Range': 'asdf'}) - self.assertEqual(response.code, 406) + self.assertEqual(response.code, 416) @wsgi_safe diff --git a/tornado/web.py b/tornado/web.py index 9e5135255..6a4f76df1 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -1760,8 +1760,11 @@ class StaticFileHandler(RequestHandler): if range_header: request_range = httputil.parse_request_range(range_header) if not request_range: - # 406: Not Acceptable - self.set_status(406) + # 416: Range Not Satisfiable + self.set_status(416) + self.set_header("Content-Type", "text/plain") + self.write(utf8("The provided Range header is not valid: %r\n" + "Note: multiple ranges are not supported")) return with open(abspath, "rb") as file: