本文整理汇总了Python中pyramid.response.Response.headers['Server']方法的典型用法代码示例。如果您正苦于以下问题:Python Response.headers['Server']方法的具体用法?Python Response.headers['Server']怎么用?Python Response.headers['Server']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.response.Response
的用法示例。
在下文中一共展示了Response.headers['Server']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import headers['Server'] [as 别名]
def __call__(self, request):
"""Processes and dispatches the request"""
if request.method != 'POST':
return httpexceptions.HTTPMethodNotAllowed(['POST'])
body = request.body
stream = None
timezone_offset = self._get_timezone_offset()
# Decode the request
try:
amf_request = remoting.decode(body, strict=self.strict,
logger=self.logger,
timezone_offset=timezone_offset)
except (pyamf.DecodeError, IOError):
if self.logger:
self.logger.exception('Error decoding AMF request')
response = "400 Bad Request\n\nThe request body was unable to " \
"be successfully decoded."
if self.debug:
response += "\n\nTraceback:\n\n%s" % gateway.format_exception()
return httpexceptions.HTTPBadRequest(detail=response)
except (KeyboardInterrupt, SystemExit):
raise
except:
if self.logger:
self.logger.exception('Unexpected error decoding AMF request')
response = ("500 Internal Server Error\n\nAn unexpected error "
"occurred whilst decoding.")
if self.debug:
response += "\n\nTraceback:\n\n%s" % gateway.format_exception()
return httpexceptions.HTTPInternalServerError(detail=response)
if self.logger:
self.logger.debug("AMF Request: %r" % amf_request)
# Process the request
try:
response = self.getResponse(request, amf_request)
except (KeyboardInterrupt, SystemExit):
raise
except:
if self.logger:
self.logger.exception('Error processing AMF request')
response = ("500 Internal Server Error\n\nThe request was "
"unable to be successfully processed.")
if self.debug:
response += "\n\nTraceback:\n\n%s" % gateway.format_exception()
return httpexceptions.HTTPInternalServerError(detail=response)
if self.logger:
self.logger.debug("AMF Response: %r" % response)
# Encode the response
try:
stream = remoting.encode(response, strict=self.strict,
timezone_offset=timezone_offset)
except:
if self.logger:
self.logger.exception('Error encoding AMF request')
response = ("500 Internal Server Error\n\nThe request was "
"unable to be encoded.")
if self.debug:
response += "\n\nTraceback:\n\n%s" % gateway.format_exception()
return httpexceptions.HTTPInternalServerError(detail=response)
buf = stream.getvalue()
http_response = Response(content_type=remoting.CONTENT_TYPE)
http_response.headers['Server'] = gateway.SERVER_NAME
http_response.write(buf)
return http_response