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


Python base.headers_to_object_info函数代码示例

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


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

示例1: test_headers_to_object_info_values

    def test_headers_to_object_info_values(self):
        headers = {"content-length": "1024", "content-type": "application/json"}
        resp = headers_to_object_info(headers.items(), 200)
        self.assertEquals(resp["length"], "1024")
        self.assertEquals(resp["type"], "application/json")

        headers["x-unused-header"] = "blahblahblah"
        self.assertEquals(resp, headers_to_object_info(headers.items(), 200))
开发者ID:helen5haha,项目名称:swift,代码行数:8,代码来源:test_base.py

示例2: test_headers_to_object_info_values

    def test_headers_to_object_info_values(self):
        headers = {
            'content-length': '1024',
            'content-type': 'application/json',
        }
        resp = headers_to_object_info(headers.items(), 200)
        self.assertEqual(resp['length'], '1024')
        self.assertEqual(resp['type'], 'application/json')

        headers['x-unused-header'] = 'blahblahblah'
        self.assertEqual(
            resp,
            headers_to_object_info(headers.items(), 200))
开发者ID:mahak,项目名称:swift,代码行数:13,代码来源:test_base.py

示例3: test_headers_to_object_info_transient_sysmeta

 def test_headers_to_object_info_transient_sysmeta(self):
     headers = {get_object_transient_sysmeta('Whatevs'): 14,
                get_object_transient_sysmeta('somethingelse'): 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEqual(len(resp['transient_sysmeta']), 2)
     self.assertEqual(resp['transient_sysmeta']['whatevs'], 14)
     self.assertEqual(resp['transient_sysmeta']['somethingelse'], 0)
开发者ID:mahak,项目名称:swift,代码行数:7,代码来源:test_base.py

示例4: test_headers_to_object_info_meta

 def test_headers_to_object_info_meta(self):
     headers = {'X-Object-Meta-Whatevs': 14,
                'x-object-meta-somethingelse': 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEqual(len(resp['meta']), 2)
     self.assertEqual(resp['meta']['whatevs'], 14)
     self.assertEqual(resp['meta']['somethingelse'], 0)
开发者ID:mahak,项目名称:swift,代码行数:7,代码来源:test_base.py

示例5: test_headers_to_object_info_sys_meta

 def test_headers_to_object_info_sys_meta(self):
     prefix = get_sys_meta_prefix("object")
     headers = {"%sWhatevs" % prefix: 14, "%ssomethingelse" % prefix: 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEquals(len(resp["sysmeta"]), 2)
     self.assertEquals(resp["sysmeta"]["whatevs"], 14)
     self.assertEquals(resp["sysmeta"]["somethingelse"], 0)
开发者ID:helen5haha,项目名称:swift,代码行数:7,代码来源:test_base.py

示例6: test_headers_to_object_info_sys_meta

 def test_headers_to_object_info_sys_meta(self):
     prefix = get_sys_meta_prefix('object')
     headers = {'%sWhatevs' % prefix: 14,
                '%ssomethingelse' % prefix: 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEqual(len(resp['sysmeta']), 2)
     self.assertEqual(resp['sysmeta']['whatevs'], 14)
     self.assertEqual(resp['sysmeta']['somethingelse'], 0)
开发者ID:mahak,项目名称:swift,代码行数:8,代码来源:test_base.py

示例7: __call__

 def __call__(self, env, start_response):
     if env['REQUEST_METHOD'] == "HEAD" and \
             env['PATH_INFO'] == '/v1/a/c2/o2':
         env_key = get_object_env_key('a', 'c2', 'o2')
         env[env_key] = headers_to_object_info(self.headers, 200)
         start_response('200 OK', self.headers)
     elif env['REQUEST_METHOD'] == "HEAD" and \
             env['PATH_INFO'] == '/v1/a/c2/o3':
         start_response('404 Not Found', [])
     else:
         # Cache the account_info (same as a real application)
         cache_key, env_key = _get_cache_key('a', None)
         env[env_key] = headers_to_account_info(self.headers, 200)
         start_response('200 OK', self.headers)
     return []
开发者ID:674009287,项目名称:swift,代码行数:15,代码来源:test_account_quotas.py

示例8: __init__

    def __init__(self, headers, env, account, container, obj):
        self.headers = headers
        self.status_int = FakeResponse_status_int
        self.environ = env
        if obj:
            env_key = get_object_env_key(account, container, obj)
        else:
            cache_key, env_key = _get_cache_key(account, container)

        if account and container and obj:
            info = headers_to_object_info(headers, FakeResponse_status_int)
        elif account and container:
            info = headers_to_container_info(headers, FakeResponse_status_int)
        else:
            info = headers_to_account_info(headers, FakeResponse_status_int)
        env[env_key] = info
开发者ID:10389030,项目名称:swift,代码行数:16,代码来源:test_base.py

示例9: __call__

 def __call__(self, env, start_response):
     if 'swift.authorize' in env:
         aresp = env['swift.authorize'](Request(env))
         if aresp:
             return aresp(env, start_response)
     if env['REQUEST_METHOD'] == "HEAD" and \
             env['PATH_INFO'] == '/v1/a/c2/o2':
         env_key = get_object_env_key('a', 'c2', 'o2')
         env.setdefault('swift.infocache', {})[env_key] = \
             headers_to_object_info(self.headers, 200)
         start_response('200 OK', self.headers)
     elif env['REQUEST_METHOD'] == "HEAD" and \
             env['PATH_INFO'] == '/v1/a/c2/o3':
         start_response('404 Not Found', [])
     else:
         # Cache the account_info (same as a real application)
         cache_key, env_key = _get_cache_key('a', None)
         env.setdefault('swift.infocache', {})[env_key] = \
             headers_to_account_info(self.headers, 200)
         start_response('200 OK', self.headers)
     return []
开发者ID:nelsonmarcos,项目名称:swift,代码行数:21,代码来源:test_account_quotas.py

示例10: test_headers_to_object_info_missing

 def test_headers_to_object_info_missing(self):
     resp = headers_to_object_info({}, 404)
     self.assertEqual(resp['status'], 404)
     self.assertIsNone(resp['length'])
     self.assertIsNone(resp['etag'])
开发者ID:mahak,项目名称:swift,代码行数:5,代码来源:test_base.py

示例11: test_headers_to_object_info_meta

 def test_headers_to_object_info_meta(self):
     headers = {"X-Object-Meta-Whatevs": 14, "x-object-meta-somethingelse": 0}
     resp = headers_to_object_info(headers.items(), 200)
     self.assertEquals(len(resp["meta"]), 2)
     self.assertEquals(resp["meta"]["whatevs"], 14)
     self.assertEquals(resp["meta"]["somethingelse"], 0)
开发者ID:helen5haha,项目名称:swift,代码行数:6,代码来源:test_base.py

示例12: test_headers_to_object_info_missing

 def test_headers_to_object_info_missing(self):
     resp = headers_to_object_info({}, 404)
     self.assertEquals(resp["status"], 404)
     self.assertEquals(resp["length"], None)
     self.assertEquals(resp["etag"], None)
开发者ID:helen5haha,项目名称:swift,代码行数:5,代码来源:test_base.py


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