mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Fixing bug #227562 by calling URLopener.http_error_default when
an invalid 401 request is being handled.
This commit is contained in:
parent
be77cf7d57
commit
e99bd17ed6
1 changed files with 18 additions and 12 deletions
|
@ -560,13 +560,19 @@ class FancyURLopener(URLopener):
|
||||||
"""Error 401 -- authentication required.
|
"""Error 401 -- authentication required.
|
||||||
See this URL for a description of the basic authentication scheme:
|
See this URL for a description of the basic authentication scheme:
|
||||||
http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt"""
|
http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt"""
|
||||||
if headers.has_key('www-authenticate'):
|
if not headers.has_key('www-authenticate'):
|
||||||
|
URLopener.http_error_default(self, url, fp,
|
||||||
|
errmsg, headers)
|
||||||
stuff = headers['www-authenticate']
|
stuff = headers['www-authenticate']
|
||||||
import re
|
import re
|
||||||
match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
|
match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
|
||||||
if match:
|
if not match:
|
||||||
|
URLopener.http_error_default(self, url, fp,
|
||||||
|
errcode, errmsg, headers)
|
||||||
scheme, realm = match.groups()
|
scheme, realm = match.groups()
|
||||||
if scheme.lower() == 'basic':
|
if scheme.lower() != 'basic':
|
||||||
|
URLopener.http_error_default(self, url, fp,
|
||||||
|
errcode, errmsg, headers)
|
||||||
name = 'retry_' + self.type + '_basic_auth'
|
name = 'retry_' + self.type + '_basic_auth'
|
||||||
if data is None:
|
if data is None:
|
||||||
return getattr(self,name)(url, realm)
|
return getattr(self,name)(url, realm)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue