From: David Wolever Date: Fri, 17 May 2013 04:11:40 +0000 (-0400) Subject: Tests for Range header X-Git-Tag: v3.1.0~68^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=167acb0f2efa4d74883a54ad9c0cce33d6c295fd;p=thirdparty%2Ftornado.git Tests for Range header --- diff --git a/tornado/test/web_test.py b/tornado/test/web_test.py index 7dcdb83d7..c305a8513 100644 --- a/tornado/test/web_test.py +++ b/tornado/test/web_test.py @@ -868,6 +868,21 @@ class StaticFileTest(WebTestCase): self.assertEqual(utf8(response.headers.get("Etag")), b'"' + self.robots_txt_hash + b'"') + def test_static_with_range(self): + response = self.fetch('/static/robots.txt', headers={ + 'Range': 'bytes=0-9'}) + self.assertEqual(response.body, b"User-agent") + self.assertEqual(utf8(response.headers.get("Etag")), + b'"' + self.robots_txt_hash + b'"') + self.assertEqual(response.headers.get("Content-Length"), "10") + self.assertEqual(response.headers.get("Content-Range"), + "0-9/26") + + def test_static_invalid_range(self): + response = self.fetch('/static/robots.txt', headers={ + 'Range': 'asdf'}) + self.assertEqual(response.code, 406) + @wsgi_safe class CustomStaticFileTest(WebTestCase):