本文整理汇总了Python中swift.proxy.controllers.base.GetOrHeadHandler.learn_size_from_content_range方法的典型用法代码示例。如果您正苦于以下问题:Python GetOrHeadHandler.learn_size_from_content_range方法的具体用法?Python GetOrHeadHandler.learn_size_from_content_range怎么用?Python GetOrHeadHandler.learn_size_from_content_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类swift.proxy.controllers.base.GetOrHeadHandler
的用法示例。
在下文中一共展示了GetOrHeadHandler.learn_size_from_content_range方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_range_fast_forward_after_data_timeout
# 需要导入模块: from swift.proxy.controllers.base import GetOrHeadHandler [as 别名]
# 或者: from swift.proxy.controllers.base.GetOrHeadHandler import learn_size_from_content_range [as 别名]
def test_range_fast_forward_after_data_timeout(self):
req = Request.blank('/')
# We get a 200 and learn that it's a 1000-byte object, but receive 0
# bytes of data, so then we get a new node, fast_forward(0), and
# send out a new request. That new request must be for all 1000
# bytes.
handler = GetOrHeadHandler(None, req, None, None, None, None, {})
handler.learn_size_from_content_range(0, 999, 1000)
handler.fast_forward(0)
self.assertEqual(handler.backend_headers['Range'], 'bytes=0-999')
# Same story as above, but a 1-byte object so we can have our byte
# indices be 0.
handler = GetOrHeadHandler(None, req, None, None, None, None, {})
handler.learn_size_from_content_range(0, 0, 1)
handler.fast_forward(0)
self.assertEqual(handler.backend_headers['Range'], 'bytes=0-0')
# last 100 bytes
handler = GetOrHeadHandler(None, req, None, None, None, None,
{'Range': 'bytes=-100'})
handler.learn_size_from_content_range(900, 999, 1000)
handler.fast_forward(0)
self.assertEqual(handler.backend_headers['Range'], 'bytes=900-999')