def handle_401(self, r, **kwargs):
if self.pos is not None:<EOL><INDENT>r.request.body.seek(self.pos)<EOL><DEDENT>num_401_calls = getattr(self, '<STR_LIT>', <NUM_LIT:1>)<EOL>s_auth = r.headers.get('<STR_LIT>', '<STR_LIT>')<EOL>if '<STR_LIT>' in s_auth.lower() and num_401_calls < <NUM_LIT:2>:<EOL><INDENT>self.num_401_calls += <NUM_LIT:1><EOL>pat = re.compile(r'<STR_LIT>', flags=re.IGNORECASE)<EOL>self.chal = parse_dict_header(pat.sub('<STR_LIT>', s_auth, count=<NUM_LIT:1>))<EOL>r.content<EOL>r.raw.release_conn()<EOL>prep = r.request.copy()<EOL>extract_cookies_to_jar(prep._cookies, r.request, r.raw)<EOL>prep.prepare_cookies(prep._cookies)<EOL>prep.headers['<STR_LIT>'] = self.build_digest_header(<EOL>prep.method, prep.url)<EOL>_r = r.connection.send(prep, **kwargs)<EOL>_r.history.append(r)<EOL>_r.request = prep<EOL>return _r<EOL><DEDENT>self.num_401_calls = <NUM_LIT:1><EOL>return r<EOL>
Takes the given response and tries digest-auth, if needed.