'Ask a resource to render itself.
@param resrc: a L{twisted.web.resource.IResource}.'

def render(self, resrc):

    try:
        body = resrc.render(self)
    except UnsupportedMethod as e:
        allowedMethods = e.allowedMethods
        if ((self.method == 'HEAD') and ('GET' in allowedMethods)):
            log.msg(('Using    GET    to    fake    a    HEAD    request    for    %s' % (resrc,)))
            self.method = 'GET'
            self._inFakeHead = True
            body = resrc.render(self)
            if (body is NOT_DONE_YET):
                log.msg(('Tried    to    fake    a    HEAD    request    for    %s,    but    it    got    away    from    me.' % resrc))
            else:
                self.setHeader('content-length', intToBytes(len(body)))
            self._inFakeHead = False
            self.method = 'HEAD'
            self.write('')
            self.finish()
            return
        if (self.method in supportedMethods):
            self.setHeader('Allow', ',    '.join(allowedMethods))
            s = ('Your    browser    approached    me    (at    %(URI)s)    with    the    method    "%(method)s".        I    only    allow    the    method%(plural)s    %(allowed)s    here.' % {'URI': escape(nativeString(self.uri)), 'method': nativeString(self.method), 'plural': (((len(allowedMethods) > 1) and 's') or ''), 'allowed': ',    '.join([nativeString(x) for x in allowedMethods])})
            epage = resource.ErrorPage(http.NOT_ALLOWED, 'Method    Not    Allowed', s)
            body = epage.render(self)
        else:
            epage = resource.ErrorPage(http.NOT_IMPLEMENTED, 'Huh?', ("I    don't    know    how    to    treat    a    %s    request." % (escape(self.method.decode('charmap')),)))
            body = epage.render(self)
    if (body == NOT_DONE_YET):
        return
    if (not isinstance(body, bytes)):
        body = resource.ErrorPage(http.INTERNAL_SERVER_ERROR, 'Request    did    not    return    bytes', ((((((('Request:    ' + util._PRE(reflect.safe_repr(self))) + '<br    />') + 'Resource:    ') + util._PRE(reflect.safe_repr(resrc))) + '<br    />') + 'Value:    ') + util._PRE(reflect.safe_repr(body)))).render(self)
    if (self.method == 'HEAD'):
        if (len(body) > 0):
            log.msg(("Warning:    HEAD    request    %s    for    resource    %s    is    returning    a    message    body.        I    think    I'll    eat    it." % (self, resrc)))
            self.setHeader('content-length', intToBytes(len(body)))
        self.write('')
    else:
        self.setHeader('content-length', intToBytes(len(body)))
        self.write(body)
    self.finish()
