def resolve_redirects(self, resp, req, stream=False, timeout=None,<EOL>verify=True, cert=None, proxies=None):
i = <NUM_LIT:0><EOL>hist = [] <EOL>while resp.is_redirect:<EOL><INDENT>prepared_request = req.copy()<EOL>if i > <NUM_LIT:0>:<EOL><INDENT>hist.append(resp)<EOL>new_hist = list(hist)<EOL>resp.history = new_hist<EOL><DEDENT>try:<EOL><INDENT>resp.content  <EOL><DEDENT>except (ChunkedEncodingError, ContentDecodingError, RuntimeError):<EOL><INDENT>resp.raw.read(decode_content=False)<EOL><DEDENT>if i >= self.max_redirects:<EOL><INDENT>raise TooManyRedirects('<STR_LIT>' % self.max_redirects)<EOL><DEDENT>resp.close()<EOL>url = resp.headers['<STR_LIT:location>']<EOL>method = req.method<EOL>if url.startswith('<STR_LIT>'):<EOL><INDENT>parsed_rurl = urlparse(resp.url)<EOL>url = '<STR_LIT>' % (parsed_rurl.scheme, url)<EOL><DEDENT>parsed = urlparse(url)<EOL>url = parsed.geturl()<EOL>if not parsed.netloc:<EOL><INDENT>url = urljoin(resp.url, requote_uri(url))<EOL><DEDENT>else:<EOL><INDENT>url = requote_uri(url)<EOL><DEDENT>prepared_request.url = to_native_string(url)<EOL>if resp.is_permanent_redirect and req.url != prepared_request.url:<EOL><INDENT>self.redirect_cache[req.url] = prepared_request.url<EOL><DEDENT>if (resp.status_code == codes.see_other and<EOL>method != '<STR_LIT>'):<EOL><INDENT>method = '<STR_LIT:GET>'<EOL><DEDENT>if resp.status_code == codes.found and method != '<STR_LIT>':<EOL><INDENT>method = '<STR_LIT:GET>'<EOL><DEDENT>if resp.status_code == codes.moved and method == '<STR_LIT:POST>':<EOL><INDENT>method = '<STR_LIT:GET>'<EOL><DEDENT>prepared_request.method = method<EOL>if resp.status_code not in (codes.temporary_redirect, codes.permanent_redirect):<EOL><INDENT>if '<STR_LIT>' in prepared_request.headers:<EOL><INDENT>del prepared_request.headers['<STR_LIT>']<EOL><DEDENT>prepared_request.body = None<EOL><DEDENT>headers = prepared_request.headers<EOL>try:<EOL><INDENT>del headers['<STR_LIT>']<EOL><DEDENT>except KeyError:<EOL><INDENT>pass<EOL><DEDENT>extract_cookies_to_jar(prepared_request._cookies, prepared_request, resp.raw)<EOL>prepared_request._cookies.update(self.cookies)<EOL>prepared_request.prepare_cookies(prepared_request._cookies)<EOL>proxies = self.rebuild_proxies(prepared_request, proxies)<EOL>self.rebuild_auth(prepared_request, resp)<EOL>req = prepared_request<EOL>resp = self.send(<EOL>req,<EOL>stream=stream,<EOL>timeout=timeout,<EOL>verify=verify,<EOL>cert=cert,<EOL>proxies=proxies,<EOL>allow_redirects=False,<EOL>)<EOL>extract_cookies_to_jar(self.cookies, prepared_request, resp.raw)<EOL>i += <NUM_LIT:1><EOL>yield resp<EOL><DEDENT>
Receives a Response. Returns a generator of Responses.