transfer_test_1.py 782 B

123456789101112131415161718
  1. def assertRangeAndContentRangeCompatible(self, request, response):
  2. request_prefix = 'bytes='
  3. self.assertIn('range', request.headers)
  4. self.assertTrue(request.headers['range'].startswith(request_prefix))
  5. request_range = request.headers['range'][len(request_prefix):]
  6. response_prefix = 'bytes '
  7. self.assertIn('content-range', response.info)
  8. response_header = response.info['content-range']
  9. self.assertTrue(response_header.startswith(response_prefix))
  10. response_range = (
  11. response_header[len(response_prefix):].partition('/')[0])
  12. msg = ('Request range ({0}) not a prefix of '
  13. 'response_range ({1})').format(
  14. request_range, response_range)
  15. self.assertTrue(response_range.startswith(request_range), msg=msg)