当前位置: 首页>>代码示例>>Python>>正文


Python GetOrHeadHandler.fast_forward方法代码示例

本文整理汇总了Python中swift.proxy.controllers.base.GetOrHeadHandler.fast_forward方法的典型用法代码示例。如果您正苦于以下问题:Python GetOrHeadHandler.fast_forward方法的具体用法?Python GetOrHeadHandler.fast_forward怎么用?Python GetOrHeadHandler.fast_forward使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在swift.proxy.controllers.base.GetOrHeadHandler的用法示例。


在下文中一共展示了GetOrHeadHandler.fast_forward方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_range_fast_forward

# 需要导入模块: from swift.proxy.controllers.base import GetOrHeadHandler [as 别名]
# 或者: from swift.proxy.controllers.base.GetOrHeadHandler import fast_forward [as 别名]
    def test_range_fast_forward(self):
        req = Request.blank('/')
        handler = GetOrHeadHandler(None, req, None, None, None, None, {})
        handler.fast_forward(50)
        self.assertEqual(handler.backend_headers['Range'], 'bytes=50-')

        handler = GetOrHeadHandler(None, req, None, None, None, None,
                                   {'Range': 'bytes=23-50'})
        handler.fast_forward(20)
        self.assertEqual(handler.backend_headers['Range'], 'bytes=43-50')
        self.assertRaises(HTTPException,
                          handler.fast_forward, 80)
        self.assertRaises(exceptions.RangeAlreadyComplete,
                          handler.fast_forward, 8)

        handler = GetOrHeadHandler(None, req, None, None, None, None,
                                   {'Range': 'bytes=23-'})
        handler.fast_forward(20)
        self.assertEqual(handler.backend_headers['Range'], 'bytes=43-')

        handler = GetOrHeadHandler(None, req, None, None, None, None,
                                   {'Range': 'bytes=-100'})
        handler.fast_forward(20)
        self.assertEqual(handler.backend_headers['Range'], 'bytes=-80')
        self.assertRaises(HTTPException,
                          handler.fast_forward, 100)
        self.assertRaises(exceptions.RangeAlreadyComplete,
                          handler.fast_forward, 80)

        handler = GetOrHeadHandler(None, req, None, None, None, None,
                                   {'Range': 'bytes=0-0'})
        self.assertRaises(exceptions.RangeAlreadyComplete,
                          handler.fast_forward, 1)
开发者ID:mahak,项目名称:swift,代码行数:35,代码来源:test_base.py

示例2: test_range_fast_forward_after_data_timeout

# 需要导入模块: from swift.proxy.controllers.base import GetOrHeadHandler [as 别名]
# 或者: from swift.proxy.controllers.base.GetOrHeadHandler import fast_forward [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')
开发者ID:mahak,项目名称:swift,代码行数:27,代码来源:test_base.py

示例3: test_range_fast_forward

# 需要导入模块: from swift.proxy.controllers.base import GetOrHeadHandler [as 别名]
# 或者: from swift.proxy.controllers.base.GetOrHeadHandler import fast_forward [as 别名]
    def test_range_fast_forward(self):
        req = Request.blank("/")
        handler = GetOrHeadHandler(None, req, None, None, None, None, {})
        handler.fast_forward(50)
        self.assertEquals(handler.backend_headers["Range"], "bytes=50-")

        handler = GetOrHeadHandler(None, req, None, None, None, None, {"Range": "bytes=23-50"})
        handler.fast_forward(20)
        self.assertEquals(handler.backend_headers["Range"], "bytes=43-50")
        self.assertRaises(HTTPException, handler.fast_forward, 80)

        handler = GetOrHeadHandler(None, req, None, None, None, None, {"Range": "bytes=23-"})
        handler.fast_forward(20)
        self.assertEquals(handler.backend_headers["Range"], "bytes=43-")

        handler = GetOrHeadHandler(None, req, None, None, None, None, {"Range": "bytes=-100"})
        handler.fast_forward(20)
        self.assertEquals(handler.backend_headers["Range"], "bytes=-80")
开发者ID:helen5haha,项目名称:swift,代码行数:20,代码来源:test_base.py


注:本文中的swift.proxy.controllers.base.GetOrHeadHandler.fast_forward方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。