summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-06-18 15:08:18 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-06-18 15:08:18 (GMT)
commit80f1b059714aeb1c6fc9f6ce1173bc8a51af7dd9 (patch)
tree8c22c0ff3e88aa668d82e46add45d9719aa8bc91 /Lib
parent2cd12528e4570ba445ff935ebfe9ec11752a0e9a (diff)
downloadcpython-80f1b059714aeb1c6fc9f6ce1173bc8a51af7dd9.zip
cpython-80f1b059714aeb1c6fc9f6ce1173bc8a51af7dd9.tar.gz
cpython-80f1b059714aeb1c6fc9f6ce1173bc8a51af7dd9.tar.bz2
Fix Issue1368368 - prompt_user_passwd() in FancyURLopener masks 401 Unauthorized error page
Diffstat (limited to 'Lib')
-rw-r--r--Lib/urllib/request.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 7760538..15e2dde 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -1866,7 +1866,8 @@ class FancyURLopener(URLopener):
else:
return self.http_error_default(url, fp, errcode, errmsg, headers)
- def http_error_401(self, url, fp, errcode, errmsg, headers, data=None):
+ def http_error_401(self, url, fp, errcode, errmsg, headers, data=None,
+ retry=False):
"""Error 401 -- authentication required.
This function supports Basic authentication only."""
if not 'www-authenticate' in headers:
@@ -1882,13 +1883,17 @@ class FancyURLopener(URLopener):
if scheme.lower() != 'basic':
URLopener.http_error_default(self, url, fp,
errcode, errmsg, headers)
+ if not retry:
+ 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 http_error_407(self, url, fp, errcode, errmsg, headers, data=None):
+ def http_error_407(self, url, fp, errcode, errmsg, headers, data=None,
+ retry=False):
"""Error 407 -- proxy authentication required.
This function supports Basic authentication only."""
if not 'proxy-authenticate' in headers:
@@ -1904,6 +1909,9 @@ class FancyURLopener(URLopener):
if scheme.lower() != 'basic':
URLopener.http_error_default(self, url, fp,
errcode, errmsg, headers)
+ if not retry:
+ URLopener.http_error_default(self, url, fp, errcode, errmsg,
+ headers)
name = 'retry_proxy_' + self.type + '_basic_auth'
if data is None:
return getattr(self,name)(url, realm)