netrc: use the NETRC environment variable (first) if set

Add test 755 to verify.

Proposed-by: Berthin Torres Callañaupa
URL: https://curl.se/mail/lib-2025-06/0015.html

Closes #17712
This commit is contained in:
Daniel Stenberg 2025-06-23 00:09:18 +02:00
parent cb9b1a4c4e
commit cb2a48bf5b
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 111 additions and 39 deletions

View file

@ -29,7 +29,8 @@ CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NETRC, long level);
This parameter controls the preference *level* of libcurl between using
usernames and passwords from your *~/.netrc* file, relative to usernames and
passwords in the URL supplied with CURLOPT_URL(3).
passwords in the URL supplied with CURLOPT_URL(3). If the `NETRC` environment
variable is set, that filename is used as the netrc file. (Added in 8.16.0)
On Windows, libcurl primarily checks for *.netrc* in *%HOME%*. If *%HOME%* is
not set on Windows, libcurl falls back to *%USERPROFILE%*. If the file does