本文整理汇总了Python中swift.proxy.controllers.base.Controller.generate_request_headers方法的典型用法代码示例。如果您正苦于以下问题:Python Controller.generate_request_headers方法的具体用法?Python Controller.generate_request_headers怎么用?Python Controller.generate_request_headers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类swift.proxy.controllers.base.Controller
的用法示例。
在下文中一共展示了Controller.generate_request_headers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_generate_request_headers
# 需要导入模块: from swift.proxy.controllers.base import Controller [as 别名]
# 或者: from swift.proxy.controllers.base.Controller import generate_request_headers [as 别名]
def test_generate_request_headers(self):
base = Controller(self.app)
src_headers = {"x-remove-base-meta-owner": "x", "x-base-meta-size": "151M", "new-owner": "Kun"}
req = Request.blank("/v1/a/c/o", headers=src_headers)
dst_headers = base.generate_request_headers(req, transfer=True)
expected_headers = {"x-base-meta-owner": "", "x-base-meta-size": "151M", "connection": "close"}
for k, v in expected_headers.iteritems():
self.assertTrue(k in dst_headers)
self.assertEqual(v, dst_headers[k])
self.assertFalse("new-owner" in dst_headers)
示例2: test_generate_request_headers_with_no_orig_req
# 需要导入模块: from swift.proxy.controllers.base import Controller [as 别名]
# 或者: from swift.proxy.controllers.base.Controller import generate_request_headers [as 别名]
def test_generate_request_headers_with_no_orig_req(self):
base = Controller(self.app)
src_headers = {'x-remove-base-meta-owner': 'x',
'x-base-meta-size': '151M',
'new-owner': 'Kun'}
dst_headers = base.generate_request_headers(None,
additional=src_headers)
expected_headers = {'x-base-meta-size': '151M',
'connection': 'close'}
for k, v in expected_headers.items():
self.assertDictContainsSubset(expected_headers, dst_headers)
self.assertEqual('', dst_headers['Referer'])
示例3: test_generate_request_headers
# 需要导入模块: from swift.proxy.controllers.base import Controller [as 别名]
# 或者: from swift.proxy.controllers.base.Controller import generate_request_headers [as 别名]
def test_generate_request_headers(self):
base = Controller(self.app)
src_headers = {'x-remove-base-meta-owner': 'x',
'x-base-meta-size': '151M',
'new-owner': 'Kun'}
req = Request.blank('/v1/a/c/o', headers=src_headers)
dst_headers = base.generate_request_headers(req, transfer=True)
expected_headers = {'x-base-meta-owner': '',
'x-base-meta-size': '151M'}
for k, v in expected_headers.iteritems():
self.assertTrue(k in dst_headers)
self.assertEqual(v, dst_headers[k])
self.assertFalse('new-owner' in dst_headers)
示例4: test_generate_request_headers_with_sysmeta
# 需要导入模块: from swift.proxy.controllers.base import Controller [as 别名]
# 或者: from swift.proxy.controllers.base.Controller import generate_request_headers [as 别名]
def test_generate_request_headers_with_sysmeta(self):
base = Controller(self.app)
good_hdrs = {"x-base-sysmeta-foo": "ok", "X-Base-sysmeta-Bar": "also ok"}
bad_hdrs = {"x-base-sysmeta-": "too short"}
hdrs = dict(good_hdrs)
hdrs.update(bad_hdrs)
req = Request.blank("/v1/a/c/o", headers=hdrs)
dst_headers = base.generate_request_headers(req, transfer=True)
for k, v in good_hdrs.iteritems():
self.assertTrue(k.lower() in dst_headers)
self.assertEqual(v, dst_headers[k.lower()])
for k, v in bad_hdrs.iteritems():
self.assertFalse(k.lower() in dst_headers)
示例5: test_generate_request_headers_with_sysmeta
# 需要导入模块: from swift.proxy.controllers.base import Controller [as 别名]
# 或者: from swift.proxy.controllers.base.Controller import generate_request_headers [as 别名]
def test_generate_request_headers_with_sysmeta(self):
base = Controller(self.app)
good_hdrs = {'x-base-sysmeta-foo': 'ok',
'X-Base-sysmeta-Bar': 'also ok'}
bad_hdrs = {'x-base-sysmeta-': 'too short'}
hdrs = dict(good_hdrs)
hdrs.update(bad_hdrs)
req = Request.blank('/v1/a/c/o', headers=hdrs)
dst_headers = base.generate_request_headers(req, transfer=True)
for k, v in good_hdrs.items():
self.assertIn(k.lower(), dst_headers)
self.assertEqual(v, dst_headers[k.lower()])
for k, v in bad_hdrs.items():
self.assertNotIn(k.lower(), dst_headers)