diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 7d96da393c..c89674e3df 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Updated field type `CurlTransportOptions.Proxy` from `std::string` to `Azure::Nullable`. This change allow to se an empty string to make libcurl ignore proxy settings from environment [](https://github.com/Azure/azure-sdk-for-cpp/issues/3537). + ### Other Changes ## 1.5.0 (2022-03-31) diff --git a/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp b/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp index 87f2258a31..a06fac3499 100644 --- a/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp @@ -49,7 +49,11 @@ namespace Azure { namespace Core { namespace Http { struct CurlTransportOptions final { /** - * @brief The string for the proxy is passed directly to the libcurl handle without any parsing + * @brief The string for the proxy is passed directly to the libcurl handle without any parsing. + * + * @details libcurl will use system's environment proxy configuration (if it is set) when the \p + * Proxy setting is not set (is null). Setting an empty string will make libcurl to ignore any + * proxy settings from the system (use no proxy). * * @remark No validation for the string is done by the Azure SDK. More about this option: * https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html. @@ -57,7 +61,7 @@ namespace Azure { namespace Core { namespace Http { * @remark The default value is an empty string (no proxy). * */ - std::string Proxy; + Azure::Nullable Proxy; /** * @brief The string for the certificate authenticator is sent to libcurl handle directly. * diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index 0eff964099..493f77e677 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -1225,7 +1225,7 @@ inline std::string GetConnectionKey(std::string const& host, CurlTransportOption { std::string key(host); key.append(!options.CAInfo.empty() ? options.CAInfo : "0"); - key.append(!options.Proxy.empty() ? options.Proxy : "0"); + key.append(options.Proxy ? (options.Proxy->empty() ? "NoProxy" : options.Proxy.Value()) : "0"); key.append(!options.SslOptions.EnableCertificateRevocationListCheck ? "1" : "0"); key.append(options.SslVerifyPeer ? "1" : "0"); key.append(options.NoSignal ? "1" : "0"); @@ -1356,13 +1356,13 @@ std::unique_ptr CurlConnectionPool::ExtractOrCreateCurlCo /******************** Curl handle options apply to all connections created * The keepAlive option is managed by the session directly. */ - if (!options.Proxy.empty()) + if (options.Proxy) { - if (!SetLibcurlOption(newHandle, CURLOPT_PROXY, options.Proxy.c_str(), &result)) + if (!SetLibcurlOption(newHandle, CURLOPT_PROXY, options.Proxy->c_str(), &result)) { throw Azure::Core::Http::TransportException( _detail::DefaultFailedToGetNewConnectionTemplate + hostDisplayName - + ". Failed to set proxy to:" + options.Proxy + ". " + + ". Failed to set proxy to:" + options.Proxy.Value() + ". " + std::string(curl_easy_strerror(result))); } }