depot_index.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:solaris-ips 作者: oracle 项目源码 文件源码
def default_error_page(status=http_client.NOT_FOUND, message="oops",
            traceback=None, version=None):
                """This function is registered as the default error page
                for CherryPy errors.  This sets the response headers to
                be uncacheable, and then returns a HTTP response."""

                response = cherrypy.response
                for key in ('Cache-Control', 'Pragma'):
                        if key in response.headers:
                                del response.headers[key]

                # Server errors are interesting, so let's log them.  In the case
                # of an internal server error, we send a 404 to the client. but
                # log the full details in the server log.
                if (status == http_client.INTERNAL_SERVER_ERROR or
                    status.startswith("500 ")):
                        # Convert the error to a 404 to obscure implementation
                        # from the client, but log the original error to the
                        # server logs.
                        error = cherrypy._cperror._HTTPErrorTemplate % \
                            {"status": http_client.NOT_FOUND,
                            "message": http_client.responses[http_client.NOT_FOUND],
                            "traceback": "",
                            "version": cherrypy.__version__}
                        print("Path that raised exception was {0}".format(
                            cherrypy.request.path_info))
                        print(message)
                        return error
                else:
                        error = cherrypy._cperror._HTTPErrorTemplate % \
                            {"status": http_client.NOT_FOUND, "message": message,
                            "traceback": "", "version": cherrypy.__version__}
                        return error
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号