Fixing bug #227562 by calling URLopener.http_error_default when

an invalid 401 request is being handled.
This commit is contained in:
Moshe Zadka 2001-02-27 06:27:04 +00:00
parent be77cf7d57
commit e99bd17ed6
1 changed files with 18 additions and 12 deletions

View File

@ -560,13 +560,19 @@ class FancyURLopener(URLopener):
"""Error 401 -- authentication required.
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"""
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']
import re
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()
if scheme.lower() == 'basic':
if scheme.lower() != 'basic':
URLopener.http_error_default(self, url, fp,
errcode, errmsg, headers)
name = 'retry_' + self.type + '_basic_auth'
if data is None:
return getattr(self,name)(url, realm)