"""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):
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={
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={
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={