summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMoshe Zadka <moshez@math.huji.ac.il>2001-02-27 06:27:04 (GMT)
committerMoshe Zadka <moshez@math.huji.ac.il>2001-02-27 06:27:04 (GMT)
commite99bd17ed6ffbb7a6deee9b80b83ce6a9e4e8b10 (patch)
tree1b6e8fc445c1aee2d1503fbfa5cdece832fa6eb6 /Lib
parentbe77cf7d57ac1e7e4262d919165471de93f3c2ab (diff)
downloadcpython-e99bd17ed6ffbb7a6deee9b80b83ce6a9e4e8b10.zip
cpython-e99bd17ed6ffbb7a6deee9b80b83ce6a9e4e8b10.tar.gz
cpython-e99bd17ed6ffbb7a6deee9b80b83ce6a9e4e8b10.tar.bz2
Fixing bug #227562 by calling URLopener.http_error_default when
an invalid 401 request is being handled.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/urllib.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 62b0787..9a2c0ba 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -560,18 +560,24 @@ 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'):
- stuff = headers['www-authenticate']
- import re
- match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
- if match:
- scheme, realm = match.groups()
- if scheme.lower() == 'basic':
- name = 'retry_' + self.type + '_basic_auth'
- if data is None:
- return getattr(self,name)(url, realm)
- else:
- return getattr(self,name)(url, realm, data)
+ 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 not match:
+ URLopener.http_error_default(self, url, fp,
+ errcode, errmsg, headers)
+ scheme, realm = match.groups()
+ 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)
+ else:
+ return getattr(self,name)(url, realm, data)
def retry_http_basic_auth(self, url, realm, data=None):
host, selector = splithost(url)