'Performs mutual auth checking if possible and requested. This handling
is applied to *all* responses, not just 401s.'

def handle_mutual_auth(self, response):

    log.debug(('handle_mutual_auth():    Handling:    %d' % response.status_code))
    if (self.mutual_authentication in (REQUIRED, OPTIONAL)):
        is_http_error = (response.status_code >= 400)
        if (_negotiate_value(response) is not None):
            log.debug('handle_mutual_auth():    Authenticating    the    server')
            if (not self.authenticate_server(response)):
                log.error('handle_mutual_auth():    Mutual    authentication    failed')
                raise MutualAuthenticationError('Unable    to    authenticate    {0}'.format(response))
            log.debug('handle_mutual_auth():    returning    {0}'.format(response))
            return response
        elif (is_http_error or (self.mutual_authentication == OPTIONAL)):
            if (not response.ok):
                log.error('handle_mutual_auth():    Mutual    authentication    unavailable    on    {0}    response'.format(response.status_code))
            if (self.mutual_authentication == REQUIRED):
                return SanitizedResponse(response)
            else:
                return response
        else:
            log.error('handle_mutual_auth():    Mutual    authentication    failed')
            raise MutualAuthenticationError('Unable    to    authenticate    {0}'.format(response))
    else:
        log.debug('handle_mutual_auth():    returning    {0}'.format(response))
        return response
