Skip to content

Commit

Permalink
give 401 warning if username/password do not work for URL
Browse files Browse the repository at this point in the history
  • Loading branch information
krpatter-intc committed Jul 26, 2018
1 parent 1a9128d commit aef521e
Show file tree
Hide file tree
Showing 2 changed files with 12 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
11 changes: 11 additions & 0 deletions src/pip/_internal/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,24 @@ 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.handle_401_again)

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

return new_resp

def handle_401_again(self, resp, **kwargs):
# warn user that they provided incorrect credentials
if resp.status_code != 401:
return resp

logger.warning('401 Error, Credentials not correct for %s',
resp.request.url)
return resp


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

0 comments on commit aef521e

Please sign in to comment.