Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward NETRC environment variable to curl, if exported #2497

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Forward NETRC environment variable to curl, if exported
resolves #2496
  • Loading branch information
Timo Strunk authored and Timo Strunk committed Apr 26, 2023
commit 52c820f4a41801578cfa96676378a38960623963
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