本文整理汇总了Python中pyramid.response.Response.headers['x-amzn-RequestId']方法的典型用法代码示例。如果您正苦于以下问题:Python Response.headers['x-amzn-RequestId']方法的具体用法?Python Response.headers['x-amzn-RequestId']怎么用?Python Response.headers['x-amzn-RequestId']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.response.Response
的用法示例。
在下文中一共展示了Response.headers['x-amzn-RequestId']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pyramid_router
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import headers['x-amzn-RequestId'] [as 别名]
def pyramid_router(request):
# extract action
target = request.headers.get('x-amz-target')
action = target.split('.', 2)[1] if target is not None else ""
post = request.json
# do the job
try:
auth = request.headers["Authorization"]
if not auth.startswith("AWS4-HMAC-SHA256"):
raise MissingAuthenticationTokenException
auth = auth[len("AWS4-HMAC-SHA256 "):]
auth = auth.split(", ")
auth = dict([x.split("=",2) for x in auth])
access_key = auth["Credential"].split("/")[0]
if access_key not in config.keys():
req_logger.error("Access denied for %s", access_key)
raise AccessDeniedException, "Can't find %s in users" % access_key
user = config_for_user(access_key)
sleep(user["DELAY_OPERATIONS"])
fail_every = user["FAIL_EVERY_N"]
if fail_every != None:
if fail_every + 1 == user[FAIL_KEY]: # hit the fail time
reset_fail(access_key)
raise InternalServerError("The server encountered an internal error trying to fulfill the request")
body = router(action, post, user)
status = '200 OK'
except DDBError as e:
body = e.to_dict()
status = '{} {}'.format(e.status, e.status_str)
user = None
# prepare output
response = Response()
response.body = json.dumps(body)
response.status = status
response.content_type = 'application/x-amz-json-1.0'
if post.has_key("request_id"): # might not be present if user auth failed
response.headers['x-amzn-RequestId'] = post['request_id'] # added by router
# done
return response
示例2: pyramid_router
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import headers['x-amzn-RequestId'] [as 别名]
def pyramid_router(request):
# extract action
target = request.headers.get('x-amz-target')
action = target.split('.', 2)[1] if target is not None else ""
post = request.json
# do the job
try:
body = router(action, post)
status = '200 OK'
except DDBError as e:
body = e.to_dict()
status = '{} {}'.format(e.status, e.status_str)
# prepare output
response = Response()
response.body = json.dumps(body)
response.status = status
response.content_type = 'application/x-amz-json-1.0'
response.headers['x-amzn-RequestId'] = post['request_id'] # added by router
# done
return response