Skip to content

Commit

Permalink
Merge pull request #5659 from patter001/master
Browse files Browse the repository at this point in the history
fix for: Incorrect username/password gives misleading error
  • Loading branch information
xavfernandez authored Oct 16, 2018
2 parents 83b879b + e3c869f commit 7f3b2c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/4833.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
give 401 warning if username/password do not work for URL
7 changes: 7 additions & 0 deletions src/pip/_internal/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,20 @@ def handle_401(self, resp, **kwargs):

# Add our new username and password to the request
req = HTTPBasicAuth(username or "", password or "")(resp.request)
req.register_hook("response", self.warn_on_401)

# Send our new request
new_resp = resp.connection.send(req, **kwargs)
new_resp.history.append(resp)

return new_resp

def warn_on_401(self, resp, **kwargs):
# warn user that they provided incorrect credentials
if resp.status_code == 401:
logger.warning('401 Error, Credentials not correct for %s',
resp.request.url)

def parse_credentials(self, netloc):
if "@" in netloc:
userinfo = netloc.rsplit("@", 1)[0]
Expand Down

0 comments on commit 7f3b2c1

Please sign in to comment.