def fetch(self, url, headers, body):
        current_url = url
        while True:
            parsed = urlparse.urlparse(current_url)
            path = parsed[2][1:]
            try:
                data = discoverdata.generateSample(path, self.base_url)
            except KeyError:
                return fetchers.HTTPResponse(status=404,
                                             final_url=current_url,
                                             headers={},
                                             body='')

            response = mkResponse(data)
            if response.status in [301, 302, 303, 307]:
                current_url = response.headers['location']
            else:
                response.final_url = current_url
                return response
dataset/ETHPy150Open CollabQ/CollabQ/openid/test/test_yadis_discover.py/TestFetcher.fetch/original