Skip to content
Myr

NetRC lookups should use host, not host+port (#1298)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Christie · committed by GitHub · parent 354c4ca · Browse files · 2 files+3 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+3 added−5 removed

  • other:+3 added−5 removed

2 files+3 added−5 removed

modified:httpx/_client.py+1 added-1 removed
380 unmodified lines
381 if username or password:382 return BasicAuth(username=username, password=password)383384 if self.trust_env and "Authorization" not in request.headers:385 credentials = self._netrc.get_credentials(request.url.authority)385 credentials = self._netrc.get_credentials(request.url.host)386 if credentials is not None:387 return BasicAuth(username=credentials[0], password=credentials[1])388389 return Auth()
1461 unmodified lines
modified:httpx/_utils.py+2 added-4 removed
145 unmodified lines
146 # Issue while reading the netrc file, ignore...147 pass148 return self._netrc_info149150 def get_credentials(151 self, authority: str152 ) -> typing.Optional[typing.Tuple[str, str]]:150 def get_credentials(self, host: str) -> typing.Optional[typing.Tuple[str, str]]:151 if self.netrc_info is None:152 return None153156 auth_info = self.netrc_info.authenticators(authority)154 auth_info = self.netrc_info.authenticators(host)155 if auth_info is None or auth_info[2] is None:156 return None157 return (auth_info[0], auth_info[2])158
378 unmodified lines