Skip to content

Commit

Permalink
Forward NETRC environment variable to curl, if exported (#2497)
Browse files Browse the repository at this point in the history
Co-authored-by: Timo Strunk <Timo.Strunk@nanomatch.com>
  • Loading branch information
timostrunk and Timo Strunk authored May 3, 2023
1 parent c5c37cc commit ffc1c99
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libmamba/src/core/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
// TODO remove all these includes later?
#include <spdlog/spdlog.h>

#include "mamba/core/mamba_fs.hpp" // for fs::exists
#include "mamba/core/util.hpp" // for hide_secrets
#include "mamba/core/environment.hpp" // for NETRC env var
#include "mamba/core/mamba_fs.hpp" // for fs::exists
#include "mamba/core/util.hpp" // for hide_secrets

#include "curl.hpp"

Expand All @@ -30,6 +31,13 @@ namespace mamba
curl_easy_setopt(handle, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);

// if NETRC is exported in ENV, we forward it to curl
std::string netrc_file = env::get("NETRC").value_or("");
if (netrc_file != "")
{
curl_easy_setopt(handle, CURLOPT_NETRC_FILE, netrc_file.c_str());
}

// This can improve throughput significantly, see
// https://github.com/curl/curl/issues/9601
curl_easy_setopt(handle, CURLOPT_BUFFERSIZE, 100 * 1024);
Expand Down

0 comments on commit ffc1c99

Please sign in to comment.