本文整理汇总了Python中wpull.protocol.http.request.Response.fields['location']方法的典型用法代码示例。如果您正苦于以下问题:Python Response.fields['location']方法的具体用法?Python Response.fields['location']怎么用?Python Response.fields['location']使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wpull.protocol.http.request.Response
的用法示例。
在下文中一共展示了Response.fields['location']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_redirect_tracker
# 需要导入模块: from wpull.protocol.http.request import Response [as 别名]
# 或者: from wpull.protocol.http.request.Response import fields['location'] [as 别名]
def test_redirect_tracker(self):
tracker = RedirectTracker(5)
self.assertFalse(tracker.is_redirect())
self.assertFalse(tracker.is_repeat())
self.assertFalse(tracker.exceeded())
self.assertFalse(tracker.next_location(raw=True))
self.assertEqual(0, tracker.count())
response = Response(200, 'OK')
tracker.load(response)
self.assertFalse(tracker.is_redirect())
self.assertFalse(tracker.is_repeat())
self.assertFalse(tracker.exceeded())
self.assertFalse(tracker.next_location())
self.assertEqual(0, tracker.count())
response = Response(303, 'See other')
response.fields['location'] = '/test'
tracker.load(response)
self.assertTrue(tracker.is_redirect())
self.assertFalse(tracker.is_repeat())
self.assertFalse(tracker.exceeded())
self.assertEqual('/test', tracker.next_location(raw=True))
self.assertEqual(1, tracker.count())
response = Response(307, 'Temporary redirect')
response.fields['location'] = '/test'
tracker.load(response)
tracker.load(response)
tracker.load(response)
tracker.load(response)
tracker.load(response)
self.assertTrue(tracker.is_redirect())
self.assertTrue(tracker.is_repeat())
self.assertTrue(tracker.exceeded())
self.assertEqual('/test', tracker.next_location(raw=True))
self.assertEqual(6, tracker.count())