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

update curl transport options to support ignore proxy from system #3564

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bugs Fixed

- Updated field type `CurlTransportOptions.Proxy` from `std::string` to `Azure::Nullable<std::string>`. 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).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo here.

se -> see

Will fix as part of #3598


### Other Changes

## 1.5.0 (2022-03-31)
Expand Down
8 changes: 6 additions & 2 deletions sdk/core/azure-core/inc/azure/core/http/curl_transport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,19 @@ 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
vhvb1989 marked this conversation as resolved.
Show resolved Hide resolved
* 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.
*
* @remark The default value is an empty string (no proxy).
*
*/
std::string Proxy;
Azure::Nullable<std::string> Proxy;
/**
* @brief The string for the certificate authenticator is sent to libcurl handle directly.
*
Expand Down
8 changes: 4 additions & 4 deletions sdk/core/azure-core/src/http/curl/curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
vhvb1989 marked this conversation as resolved.
Show resolved Hide resolved
key.append(!options.SslOptions.EnableCertificateRevocationListCheck ? "1" : "0");
key.append(options.SslVerifyPeer ? "1" : "0");
key.append(options.NoSignal ? "1" : "0");
Expand Down Expand Up @@ -1356,13 +1356,13 @@ std::unique_ptr<CurlNetworkConnection> 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)));
}
}
Expand Down