@classmethod
    def http(cls, status_code, msg="", err_list=None, headers=None):
        """Raise an HTTP status code.

        Useful for returning status
        codes like 401 Unauthorized or 403 Forbidden.

        :param status_code: the HTTP status code as an integer
        :param msg: the message to send along, as a string
        :param err_list: list of fields with errors
        :param headers: the headers to send along, as a dictionary
        """
        class _nocontent(web.HTTPError):
            message = 'No Content'

            def __init__(self):
                super(_nocontent, self).__init__(
                    status='204 No Content',
                    data=self.message
                )

        exc_status_map = {
            200: web.ok,
            201: web.created,
            202: web.accepted,
            204: _nocontent,

            301: web.redirect,
            302: web.found,

            400: web.badrequest,
            401: web.unauthorized,
            403: web.forbidden,
            404: web.notfound,
            405: web.nomethod,
            406: web.notacceptable,
            409: web.conflict,
            410: web.gone,
            415: web.unsupportedmediatype,

            500: web.internalerror,
        }

        # web.py has a poor exception design: some of them receive
        # the `message` argument and some of them not. the only
        # solution to set custom message is to assign message directly
        # to the `data` attribute. though, that won't work for
        # the `internalerror` because it tries to do magic with
        # application context without explicit `message` argument.
        try:
            exc = exc_status_map[status_code](message=msg)
        except __HOLE__:
            exc = exc_status_map[status_code]()
        exc.data = msg
        exc.err_list = err_list or []
        exc.status_code = status_code

        headers = headers or {}
        for key, value in headers.items():
            web.header(key, value)

        return exc
dataset/ETHPy150Open openstack/fuel-web/nailgun/nailgun/api/v1/handlers/base.py/BaseHandler.http