docs: def rebuild_auth(self, prepared_request, response):
          """When being redirected we may want to strip authentication from the
          request to avoid leaking credentials. This method intelligently removes
          and reapplies authentication where possible to avoid credential loss.
          """
          headers = prepared_request.headers
          url = prepared_request.url
  
          if 'Authorization' in headers:
              # If we get redirected to a new host, we should strip out any
              # authentication headers.
              original_parsed = urlparse(response.request.url)
              redirect_parsed = urlparse(url)
  
              if (original_parsed.hostname != redirect_parsed.hostname):
                  del headers['Authorization']
  
          # .netrc might have more auth for us on our new host.
          new_auth = get_netrc_auth(url) if self.trust_env else None
          if new_auth is not None:
              prepared_request.prepare_auth(new_auth)
  
          return