本文整理汇总了Python中swift.common.swob.Response.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Response.__init__方法的具体用法?Python Response.__init__怎么用?Python Response.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类swift.common.swob.Response
的用法示例。
在下文中一共展示了Response.__init__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from swift.common.swob import Response [as 别名]
# 或者: from swift.common.swob.Response import __init__ [as 别名]
def __init__(self, s3_req, sw_req, sw_resp):
if sw_resp.app_iter:
body = None
app_iter = sw_resp.app_iter
else:
body = sw_resp.body
app_iter = None
self.swift3_headers = HeaderKeyDict()
self.sw_headers = HeaderKeyDict()
headers = HeaderKeyDict()
for key, val in sw_resp.headers.iteritems():
_key = key.lower()
if "[swift3]" in _key:
self.swift3_headers[_key] = val
if _key == 'x-object-meta-[swift3]-versioned' and \
'x-object-meta-[swift3]-timestamp' in sw_resp.headers:
from swift3.request import VersionId
ts_key = 'x-object-meta-[swift3]-timestamp'
headers['x-amz-version-id'] = \
str(VersionId(sw_resp.headers[ts_key]))
if _key == 'x-object-meta-[swift3]-delete-marker':
headers['x-amz-delete-marker'] = val
if _key == 'x-object-meta-[swift3]-missing-meta':
headers['x-amz-missing-meta'] = val
elif _key.startswith('x-object-meta-'):
headers['x-amz-meta-' + key[14:]] = val
elif _key in ('content-length', 'content-type',
'content-range', 'content-encoding',
'etag', 'last-modified'):
headers[key] = val
else:
self.sw_headers[key] = val
Response.__init__(self, status=sw_resp.status, headers=headers,
request=sw_req, body=body, app_iter=app_iter,
conditional_response=sw_resp.conditional_response)
self.environ.update(sw_resp.environ)
self.s3_req = s3_req