]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
NetRC lookups should use host, not host+port (#1298)
authorTom Christie <tom@tomchristie.com>
Fri, 18 Sep 2020 10:50:13 +0000 (11:50 +0100)
committerGitHub <noreply@github.com>
Fri, 18 Sep 2020 10:50:13 +0000 (11:50 +0100)
httpx/_client.py
httpx/_utils.py

index e5b53d4f5fdd537646829ae464b5fbfd38fa9bab..5e2b3c6b681d0991a9c8c34023d59b795bb0ced2 100644 (file)
@@ -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])
 
index aa670724cbadfffb166212816990e252b74ba7dc..75c92fd827f1858db95719f7afbef78da4460f32 100644 (file)
@@ -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])