]> granicus.if.org Git - python/commitdiff
Fixing bug #227562 by calling URLopener.http_error_default when
authorMoshe Zadka <moshez@math.huji.ac.il>
Tue, 27 Feb 2001 06:27:04 +0000 (06:27 +0000)
committerMoshe Zadka <moshez@math.huji.ac.il>
Tue, 27 Feb 2001 06:27:04 +0000 (06:27 +0000)
an invalid 401 request is being handled.

Lib/urllib.py

index 62b0787a58b3ef95305af3578f431f60f65ad23b..9a2c0baebbd56e749cd9c8726be4a991f869fe0f 100644 (file)
@@ -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)