'If the given url contains auth info or if a normal request gets a 401
response, an attempt is made to fetch the resource using basic HTTP
auth.'

def __call__(self, url):

    (url, username, password) = self.extract_credentials(url)
    if (username is None):
        try:
            response = urllib2.urlopen(self.get_request(url))
        except urllib2.HTTPError:
            e = sys.exc_info()[1]
            if (e.code != 401):
                raise
            response = self.get_response(url)
    else:
        response = self.get_response(url, username, password)
    return response
