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

Allow usage of system default proxy #2679

Merged
merged 1 commit into from
Sep 21, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ namespace Aws
* Override the http endpoint used to talk to a service.
*/
Aws::String endpointOverride;

/**
* Allow HTTP client to discover system proxy setting. Off by default for legacy reasons.
*/
bool allowSystemProxy = false;
/**
* If you have users going through a proxy, set the proxy scheme here. Default HTTP
*/
Expand Down
11 changes: 6 additions & 5 deletions src/aws-cpp-sdk-core/include/aws/core/http/curl/CurlHttpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class AWS_CORE_API CurlHttpClient: public HttpClient

private:
mutable CurlHandleContainer m_curlHandleContainer;
bool m_isUsingProxy;
bool m_isAllowSystemProxy = false;
bool m_isUsingProxy = false;
Aws::String m_proxyUserName;
Aws::String m_proxyPassword;
Aws::String m_proxyScheme;
Expand All @@ -59,13 +60,13 @@ class AWS_CORE_API CurlHttpClient: public HttpClient
Aws::String m_proxySSLKeyPath;
Aws::String m_proxySSLKeyType;
Aws::String m_proxyKeyPasswd;
unsigned m_proxyPort;
unsigned m_proxyPort = 0;
Aws::String m_nonProxyHosts;
bool m_verifySSL;
bool m_verifySSL = true;
Aws::String m_caPath;
Aws::String m_caFile;
bool m_disableExpectHeader;
bool m_allowRedirects;
bool m_disableExpectHeader = false;
bool m_allowRedirects = false;
static std::atomic<bool> isInit;
std::shared_ptr<smithy::components::tracing::TelemetryProvider> m_telemetryProvider;
};
Expand Down
7 changes: 5 additions & 2 deletions src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ CurlHttpClient::CurlHttpClient(const ClientConfiguration& clientConfig) :
Base(),
m_curlHandleContainer(clientConfig.maxConnections, clientConfig.httpRequestTimeoutMs, clientConfig.connectTimeoutMs, clientConfig.enableTcpKeepAlive,
clientConfig.tcpKeepAliveIntervalMs, clientConfig.requestTimeoutMs, clientConfig.lowSpeedLimit, clientConfig.version),
m_isUsingProxy(!clientConfig.proxyHost.empty()), m_proxyUserName(clientConfig.proxyUserName),
m_isAllowSystemProxy(clientConfig.allowSystemProxy), m_isUsingProxy(!clientConfig.proxyHost.empty()), m_proxyUserName(clientConfig.proxyUserName),
m_proxyPassword(clientConfig.proxyPassword), m_proxyScheme(SchemeMapper::ToString(clientConfig.proxyScheme)), m_proxyHost(clientConfig.proxyHost),
m_proxySSLCertPath(clientConfig.proxySSLCertPath), m_proxySSLCertType(clientConfig.proxySSLCertType),
m_proxySSLKeyPath(clientConfig.proxySSLKeyPath), m_proxySSLKeyType(clientConfig.proxySSLKeyType),
Expand Down Expand Up @@ -763,7 +763,10 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr<
}
else
{
curl_easy_setopt(connectionHandle, CURLOPT_PROXY, "");
if(!m_isAllowSystemProxy)
{
curl_easy_setopt(connectionHandle, CURLOPT_PROXY, "");
}
}

if (request->GetContentBody())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ WinHttpSyncHttpClient::WinHttpSyncHttpClient(const ClientConfiguration& config)
AWS_LOGSTREAM_INFO(GetLogTag(), "Creating http client with user agent " << config.userAgent << " with max connections " << config.maxConnections
<< " request timeout " << config.requestTimeoutMs << ",and connect timeout " << config.connectTimeoutMs);

DWORD winhttpFlags = WINHTTP_ACCESS_TYPE_NO_PROXY;
#if defined(WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY)
DWORD winhttpFlags = config.allowSystemProxy ? WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY : WINHTTP_ACCESS_TYPE_NO_PROXY;
#else
DWORD winhttpFlags = config.allowSystemProxy ? WINHTTP_ACCESS_TYPE_DEFAULT_PROXY : WINHTTP_ACCESS_TYPE_NO_PROXY;
#endif
const char* proxyHosts = nullptr;
Aws::String strProxyHosts;

Expand Down
Loading