'Modify cherrypy.response status, headers, and body to represent self.
CherryPy uses this internally, but you can also use it to create an
HTTPRedirect object and set its output without *raising* the exception.'

def set_response(self):

    import cherrypy
    response = cherrypy.serving.response
    response.status = status = self.status
    if (status in (300, 301, 302, 303, 307)):
        response.headers['Content-Type'] = 'text/html;charset=utf-8'
        response.headers['Location'] = self.urls[0]
        msg = {300: "This    resource    can    be    found    at    <a    href='%s'>%s</a>.", 301: "This    resource    has    permanently    moved    to    <a    href='%s'>%s</a>.", 302: "This    resource    resides    temporarily    at    <a    href='%s'>%s</a>.", 303: "This    resource    can    be    found    at    <a    href='%s'>%s</a>.", 307: "This    resource    has    moved    temporarily    to    <a    href='%s'>%s</a>."}[status]
        msgs = [(msg % (u, u)) for u in self.urls]
        response.body = ntob('<br    />\n'.join(msgs), 'utf-8')
        response.headers.pop('Content-Length', None)
    elif (status == 304):
        for key in ('Allow', 'Content-Encoding', 'Content-Language', 'Content-Length', 'Content-Location', 'Content-MD5', 'Content-Range', 'Content-Type', 'Expires', 'Last-Modified'):
            if (key in response.headers):
                del response.headers[key]
        response.body = None
        response.headers.pop('Content-Length', None)
    elif (status == 305):
        response.headers['Location'] = self.urls[0]
        response.body = None
        response.headers.pop('Content-Length', None)
    else:
        raise ValueError(('The    %s    status    code    is    unknown.' % status))
