Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4bb5c27

Browse files
committed
Fix Issue8797 - Reset the basic auth retry count when response code is not 401.
1 parent 0e10206 commit 4bb5c27

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lib/urllib/request.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,10 @@ def http_error_auth_reqed(self, authreq, host, req, headers):
799799
if mo:
800800
scheme, quote, realm = mo.groups()
801801
if scheme.lower() == 'basic':
802-
return self.retry_http_basic_auth(host, req, realm)
802+
response = self.retry_http_basic_auth(host, req, realm)
803+
if response and response.code != 401:
804+
self.retried = 0
805+
return response
803806

804807
def retry_http_basic_auth(self, host, req, realm):
805808
user, pw = self.passwd.find_user_password(realm, host)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ Extensions
132132
Library
133133
-------
134134

135+
- Issue #8797: urllib2 does a retry for Basic Authentication failure instead of
136+
falling into recursion.
137+
135138
- Issue #1194222: email.utils.parsedate now returns RFC2822 compliant four
136139
character years even if the message contains RFC822 two character years.
137140

0 commit comments

Comments
 (0)