当前位置: 首页>>代码示例>>Python>>正文


Python http_error.HTTPError类代码示例

本文整理汇总了Python中falcon.http_error.HTTPError的典型用法代码示例。如果您正苦于以下问题:Python HTTPError类的具体用法?Python HTTPError怎么用?Python HTTPError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HTTPError类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, title, description, retry_after, **kwargs):
        """Initialize

        Args:
            title: Human-friendly error title. Set to None if you wish Falcon
                to return an empty response body (all remaining args will
                be ignored except for headers.) Do this only when you don't
                wish to disclose sensitive information about why a request was
                refused, or if the status and headers are self-descriptive.
            description: Human-friendly description of the error, along with a
                helpful suggestion or two (default None).
            retry_after: Value for the Retry-After header. If a date object,
                will serialize as an HTTP date. Otherwise, a non-negative int
                is expected, representing the number of seconds to wait. See
                also: http://goo.gl/DIrWr
            headers: A dictionary of extra headers to return in the
                response to the client (default None).
            href: A URL someone can visit to find out more information
                (default None).
            href_rel: If href is given, use this value for the rel
                attribute (default 'doc').
            href_text: If href is given, use this as the friendly
                title/description for the link (defaults to "API documentation
                for this error").
            code: An internal code that customers can reference in their
                support request or to help them when searching for knowledge
                base articles related to this error.
        """

        headers = kwargs.setdefault('headers', {})
        headers['Retry-After'] = str(retry_after)
        HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
开发者ID:Bengt,项目名称:falcon,代码行数:32,代码来源:exceptions.py

示例2: __init__

    def __init__(self, title, description, retry_after, **kwargs):
        """Initialize

        """

        headers = kwargs.setdefault('headers', {})
        headers['Retry-After'] = str(retry_after)
        HTTPError.__init__(self, status.HTTP_503, title, description, **kwargs)
开发者ID:TinBane,项目名称:falcon,代码行数:8,代码来源:exceptions.py

示例3: __init__

    def __init__(self, title, description, **kwargs):
        headers = kwargs.setdefault('headers', {})

        scheme = kwargs.pop('scheme', None)
        if scheme is not None:
            headers['WWW-Authenticate'] = scheme

        HTTPError.__init__(self, status.HTTP_401, title, description, **kwargs)
开发者ID:eerwitt,项目名称:falcon,代码行数:8,代码来源:errors.py

示例4: __init__

    def __init__(self, allowed_methods, **kwargs):
        HTTPError.__init__(self, status.HTTP_405, 'Method not allowed',
                           **kwargs)

        if kwargs:
            title = 'Method not allowed'
        else:
            # NOTE(kgriffs): Trigger an empty body in the response; 405
            # responses don't usually have bodies, so we only send one
            # if the caller indicates they want one, by way of specifying
            # a description, href, and/or other details.
            title = None

        # NOTE(kgriffs): Inject the "Allow" header so it will be included
        # in the HTTP response.
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, title, **kwargs)
开发者ID:B-Rich,项目名称:falcon,代码行数:19,代码来源:exceptions.py

示例5: __init__

    def __init__(self, allowed_methods, **kwargs):
        HTTPError.__init__(self, status.HTTP_405, 'Method not allowed',
                           **kwargs)

        # NOTE(kgriffs): Trigger an empty body in the response; 405
        # responses don't usually have bodies, so we only send one
        # if the caller indicates they want one by providing some
        # details in the kwargs.
        if kwargs:
            title = 'Method not allowed'
            self._has_representation = True
        else:
            title = None
            self._has_representation = False

        # NOTE(kgriffs): Inject the "Allow" header so it will be included
        # in the HTTP response.
        headers = kwargs.setdefault('headers', {})
        headers['Allow'] = ', '.join(allowed_methods)

        HTTPError.__init__(self, status.HTTP_405, title=title, **kwargs)
开发者ID:perigee,项目名称:falcon,代码行数:21,代码来源:exceptions.py

示例6: __init__

 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, HTTP_400, title, description, **kwargs)
开发者ID:abg,项目名称:falcon,代码行数:2,代码来源:exceptions.py

示例7: __init__

 def __init__(self, description, **kwargs):
     HTTPError.__init__(self, status.HTTP_415, "Unsupported Media Type", description, **kwargs)
开发者ID:marchon,项目名称:falcon,代码行数:2,代码来源:exceptions.py

示例8: __init__

 def __init__(self, title, description, **kwargs):
     HTTPError.__init__(self, '422 Unprocessable Entity', title, description, **kwargs)
开发者ID:jgrassler,项目名称:monasca-api,代码行数:2,代码来源:exceptions.py


注:本文中的falcon.http_error.HTTPError类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。