bug fix for a bug reported by nightman (RuntimeError: maximum recursion depth exceeded)

This commit is contained in:
Miroslav Stampar 2011-01-05 11:36:40 +00:00
parent 7ae5192070
commit 042e3f76ba

View File

@ -16,7 +16,7 @@ class SmartHTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler):
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
urllib2.HTTPBasicAuthHandler.__init__(self, *args, **kwargs) urllib2.HTTPBasicAuthHandler.__init__(self, *args, **kwargs)
self.retried_req = None self.retried_req = []
def reset_retry_count(self): def reset_retry_count(self):
# Python 2.6.5 will call this on 401 or 407 errors and thus loop # Python 2.6.5 will call this on 401 or 407 errors and thus loop
@ -26,8 +26,8 @@ class SmartHTTPBasicAuthHandler(urllib2.HTTPBasicAuthHandler):
def http_error_auth_reqed(self, auth_header, host, req, headers): def http_error_auth_reqed(self, auth_header, host, req, headers):
# Reset the retry counter once for each request. # Reset the retry counter once for each request.
if req is not self.retried_req: if req not in self.retried_req:
self.retried_req = req self.retried_req.append(req)
self.retried = 0 self.retried = 0
return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed( return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed(
self, auth_header, host, req, headers) self, auth_header, host, req, headers)