本文整理汇总了Python中swift.common.swob.Request.as_referer方法的典型用法代码示例。如果您正苦于以下问题:Python Request.as_referer方法的具体用法?Python Request.as_referer怎么用?Python Request.as_referer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类swift.common.swob.Request
的用法示例。
在下文中一共展示了Request.as_referer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: transition
# 需要导入模块: from swift.common.swob import Request [as 别名]
# 或者: from swift.common.swob.Request import as_referer [as 别名]
def transition(self, env):
# GET Object body
req = Request(copy(env))
req.method = 'GET'
resp = req.get_response(self.app)
obj_body = resp.body
# Glacier로 업로드
tmpfile = self.save_to_tempfile(obj_body)
try:
glacier = self._init_glacier()
archive_id = glacier.upload_archive(tmpfile)
glacier_obj = make_glacier_hidden_object_name(self.obj, archive_id)
except Exception as e:
return Response(status=HTTP_INTERNAL_SERVER_ERROR, body=e.message)
finally:
self.delete_tempfile(tmpfile)
# Object를 0KB로 만들기
req = Request(copy(env))
req.headers[GLACIER_FLAG_META] = True
resp = req.get_response(self.app)
# Glacier Hidden account에 기록
glacier_account = self.glacier_account_prefix + self.account
part, nodes = self.container_ring.get_nodes(glacier_account,
self.container)
hidden_path = '/%s/%s/%s' % (glacier_account, self.container,
glacier_obj)
for node in nodes:
ip = node['ip']
port = node['port']
dev = node['device']
headers = dict()
headers['user-agent'] = 'transition-middleware'
headers['X-Timestamp'] = normalize_timestamp(time.time())
headers['referer'] = req.as_referer()
headers['x-size'] = '0'
headers['x-content-type'] = 'text/plain'
headers['x-etag'] = 'd41d8cd98f00b204e9800998ecf8427e'
conn = http_connect(ip, port, dev, part, 'PUT', hidden_path,
headers)
conn.getresponse().read()
return Response(status=HTTP_NO_CONTENT)