From: Tom Christie Date: Fri, 18 Sep 2020 10:50:13 +0000 (+0100) Subject: NetRC lookups should use host, not host+port (#1298) X-Git-Tag: 0.15.0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed2768268644b3e3b173d4883af434fa29dbb418;p=thirdparty%2Fhttpx.git NetRC lookups should use host, not host+port (#1298) --- diff --git a/httpx/_client.py b/httpx/_client.py index e5b53d4f..5e2b3c6b 100644 --- a/httpx/_client.py +++ b/httpx/_client.py @@ -382,7 +382,7 @@ class BaseClient: return BasicAuth(username=username, password=password) if self.trust_env and "Authorization" not in request.headers: - credentials = self._netrc.get_credentials(request.url.authority) + credentials = self._netrc.get_credentials(request.url.host) if credentials is not None: return BasicAuth(username=credentials[0], password=credentials[1]) diff --git a/httpx/_utils.py b/httpx/_utils.py index aa670724..75c92fd8 100644 --- a/httpx/_utils.py +++ b/httpx/_utils.py @@ -147,13 +147,11 @@ class NetRCInfo: pass return self._netrc_info - def get_credentials( - self, authority: str - ) -> typing.Optional[typing.Tuple[str, str]]: + def get_credentials(self, host: str) -> typing.Optional[typing.Tuple[str, str]]: if self.netrc_info is None: return None - auth_info = self.netrc_info.authenticators(authority) + auth_info = self.netrc_info.authenticators(host) if auth_info is None or auth_info[2] is None: return None return (auth_info[0], auth_info[2])