diff options
author | Kevin R Patterson <kevin.r.patterson@intel.com> | 2018-07-26 17:14:16 -0500 |
---|---|---|
committer | Kevin R Patterson <kevin.r.patterson@intel.com> | 2018-07-26 17:14:16 -0500 |
commit | aef521ee6132c071b2a599540cc994f12feef8e0 (patch) | |
tree | 686b58df77c01fb1e13b9f3807a2e16a1933af3c | |
parent | 1a9128dcfc8fb4eb81e3fffd03e4a9693f8c1450 (diff) | |
download | pip-aef521ee6132c071b2a599540cc994f12feef8e0.tar.gz |
give 401 warning if username/password do not work for URL
-rw-r--r-- | news/4833.bugfix | 1 | ||||
-rw-r--r-- | src/pip/_internal/download.py | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/news/4833.bugfix b/news/4833.bugfix new file mode 100644 index 000000000..9bb9fdaa9 --- /dev/null +++ b/news/4833.bugfix @@ -0,0 +1 @@ +give 401 warning if username/password do not work for URL diff --git a/src/pip/_internal/download.py b/src/pip/_internal/download.py index 96f3b65c6..9506c17d4 100644 --- a/src/pip/_internal/download.py +++ b/src/pip/_internal/download.py @@ -199,6 +199,7 @@ class MultiDomainBasicAuth(AuthBase): # 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) @@ -206,6 +207,16 @@ class MultiDomainBasicAuth(AuthBase): 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] |