# Path: pants/http/utils.py
# HTTP = {
#     101: 'Switching Protocols',
#     200: 'OK',
#     201: 'Created',
#     202: 'Accepted',
#     203: 'Non-Authoritative Information',
#     204: 'No Content',
#     205: 'Reset Content',
#     206: 'Partial Content',
#     300: 'Multiple Choices',
#     301: 'Moved Permanently',
#     302: 'Found',
#     303: 'See Other',
#     304: 'Not Modified',
#     305: 'Use Proxy',
#     306: 'No Longer Used',
#     307: 'Temporary Redirect',
#     400: 'Bad Request',
#     401: 'Not Authorised',
#     402: 'Payment Required',
#     403: 'Forbidden',
#     404: 'Not Found',
#     405: 'Method Not Allowed',
#     406: 'Not Acceptable',
#     407: 'Proxy Authentication Required',
#     408: 'Request Timeout',
#     409: 'Conflict',
#     410: 'Gone',
#     411: 'Length Required',
#     412: 'Precondition Failed',
#     413: 'Request Entity Too Large',
#     414: 'Request URI Too Long',
#     415: 'Unsupported Media Type',
#     416: 'Requested Range Not Satisfiable',
#     417: 'Expectation Failed',
#     418: "I'm a teapot",
#     426: "Upgrade Required",
#     500: 'Internal Server Error',
#     501: 'Not Implemented',
#     502: 'Bad Gateway',
#     503: 'Service Unavailable',
#     504: 'Gateway Timeout',
#     505: 'HTTP Version Not Supported'
# }
# 
# SERVER      = 'HTTPants (pants/%s)' % pants_version
# 
# SERVER_URL  = 'http://www.pantspowered.org/'


import base64
import logging
import re
import string
import sys
from pants.http.utils import HTTP, SERVER, SERVER_URL
    from pkg_resources import resource_string
# Special Exceptions
###############################################################################

class HTTPException(Exception):
    """
    Raising an instance of HTTPException will cause the Application to render
    an error page out to the client with the given
    `HTTP status code <http://en.wikipedia.org/wiki/List_of_HTTP_status_codes>`_,
    message, and any provided headers.

    This is, generally, preferable to allowing an exception of a different
    type to bubble up to the Application, which would result in a
    ``500 Internal Server Error`` page.

    The :func:`abort` helper function makes it easy to raise instances of
    this exception.

    =========  ============
    Argument   Description
    =========  ============
    status     *Optional.* The `HTTP status code <http://en.wikipedia.org/wiki/List_of_HTTP_status_codes>`_ to generate an error page for. If this isn't specified, a ``404 Not Found`` page will be generated.
    message    *Optional.* A text message to display on the error page.
    headers    *Optional.* A dict of extra HTTP headers to return with the rendered page.
    =========  ============
    """
    def __init__(self, status=404, message=None, headers=None):
        super(HTTPException, self).__init__(status, message, headers)

    def __str__(self):
        return "%d %s [message=%r, headers=%r]" % \

# Path: pants/http/utils.py
# HTTP = {
#     101: 'Switching Protocols',
#     200: 'OK',
#     201: 'Created',
#     202: 'Accepted',
#     203: 'Non-Authoritative Information',
#     204: 'No Content',
#     205: 'Reset Content',
#     206: 'Partial Content',
#     300: 'Multiple Choices',
#     301: 'Moved Permanently',
#     302: 'Found',
#     303: 'See Other',
#     304: 'Not Modified',
#     305: 'Use Proxy',
#     306: 'No Longer Used',
#     307: 'Temporary Redirect',
#     400: 'Bad Request',
#     401: 'Not Authorised',
#     402: 'Payment Required',
#     403: 'Forbidden',
#     404: 'Not Found',
#     405: 'Method Not Allowed',
#     406: 'Not Acceptable',
#     407: 'Proxy Authentication Required',
#     408: 'Request Timeout',
#     409: 'Conflict',
#     410: 'Gone',
#     411: 'Length Required',
#     412: 'Precondition Failed',
#     413: 'Request Entity Too Large',
#     414: 'Request URI Too Long',
#     415: 'Unsupported Media Type',
#     416: 'Requested Range Not Satisfiable',
#     417: 'Expectation Failed',
#     418: "I'm a teapot",
#     426: "Upgrade Required",
#     500: 'Internal Server Error',
#     501: 'Not Implemented',
#     502: 'Bad Gateway',
#     503: 'Service Unavailable',
#     504: 'Gateway Timeout',
#     505: 'HTTP Version Not Supported'
# }
# 
# SERVER      = 'HTTPants (pants/%s)' % pants_version
# 
# SERVER_URL  = 'http://www.pantspowered.org/'


# Path: pants/web/utils.py
import base64
import logging
import re
import string
import sys
from pants.http.utils import HTTP, SERVER, SERVER_URL
    from pkg_resources import resource_string

# Special Exceptions
###############################################################################

class HTTPException(Exception):
    """
    Raising an instance of HTTPException will cause the Application to render
    an error page out to the client with the given
    `HTTP status code <http://en.wikipedia.org/wiki/List_of_HTTP_status_codes>`_,
    message, and any provided headers.

    This is, generally, preferable to allowing an exception of a different
    type to bubble up to the Application, which would result in a
    ``500 Internal Server Error`` page.

    The :func:`abort` helper function makes it easy to raise instances of
    this exception.

    =========  ============
    Argument   Description
    =========  ============
    status     *Optional.* The `HTTP status code <http://en.wikipedia.org/wiki/List_of_HTTP_status_codes>`_ to generate an error page for. If this isn't specified, a ``404 Not Found`` page will be generated.
    message    *Optional.* A text message to display on the error page.
    headers    *Optional.* A dict of extra HTTP headers to return with the rendered page.
    =========  ============
    """
    def __init__(self, status=404, message=None, headers=None):
        super(HTTPException, self).__init__(status, message, headers)

    def __str__(self):
        return "%d %s [message=%r, headers=%r]" % \

            (self.status, HTTP.get(self.status, ''), self.args[1], self.args[2])