From cf179491ca37b950374ee5dda99190b8635d1586 Mon Sep 17 00:00:00 2001 From: Jerry Yuan <72721671+siwei-yuan@users.noreply.github.com> Date: Mon, 9 Oct 2023 09:04:47 -0700 Subject: [PATCH 1/2] Add Windows version checking before setting proxy flag --- .../source/http/windows/WinHttpSyncHttpClient.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/aws-cpp-sdk-core/source/http/windows/WinHttpSyncHttpClient.cpp b/src/aws-cpp-sdk-core/source/http/windows/WinHttpSyncHttpClient.cpp index 07b90b8ab8d..6c28808f72d 100644 --- a/src/aws-cpp-sdk-core/source/http/windows/WinHttpSyncHttpClient.cpp +++ b/src/aws-cpp-sdk-core/source/http/windows/WinHttpSyncHttpClient.cpp @@ -21,6 +21,7 @@ #include #include #include +#include using namespace Aws::Client; using namespace Aws::Http; @@ -52,10 +53,16 @@ WinHttpSyncHttpClient::WinHttpSyncHttpClient(const ClientConfiguration& config) << " request timeout " << config.requestTimeoutMs << ",and connect timeout " << config.connectTimeoutMs); #if defined(WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY) - DWORD winhttpFlags = config.allowSystemProxy ? WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY : WINHTTP_ACCESS_TYPE_NO_PROXY; + DWORD winhttpFlags; + if (config.allowSystemProxy) { + winhttpFlags = IsWindows8Point1OrGreater()? WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY : WINHTTP_ACCESS_TYPE_DEFAULT_PROXY; + } else { + winhttpFlags = 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; From 46fa468c8e55391340ce385294483ec2e9d3a25c Mon Sep 17 00:00:00 2001 From: Jerry Yuan <72721671+siwei-yuan@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:48:58 -0700 Subject: [PATCH 2/2] Simplify proxy flag evaluation logic --- .../source/http/windows/WinHttpSyncHttpClient.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/aws-cpp-sdk-core/source/http/windows/WinHttpSyncHttpClient.cpp b/src/aws-cpp-sdk-core/source/http/windows/WinHttpSyncHttpClient.cpp index 6c28808f72d..6823f0d47aa 100644 --- a/src/aws-cpp-sdk-core/source/http/windows/WinHttpSyncHttpClient.cpp +++ b/src/aws-cpp-sdk-core/source/http/windows/WinHttpSyncHttpClient.cpp @@ -52,15 +52,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 = config.allowSystemProxy ? WINHTTP_ACCESS_TYPE_DEFAULT_PROXY : WINHTTP_ACCESS_TYPE_NO_PROXY; #if defined(WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY) - DWORD winhttpFlags; - if (config.allowSystemProxy) { - winhttpFlags = IsWindows8Point1OrGreater()? WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY : WINHTTP_ACCESS_TYPE_DEFAULT_PROXY; - } else { - winhttpFlags = WINHTTP_ACCESS_TYPE_NO_PROXY; + if (config.allowSystemProxy && IsWindows8Point1OrGreater()) { + winhttpFlags = WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY; } -#else - DWORD winhttpFlags = config.allowSystemProxy ? WINHTTP_ACCESS_TYPE_DEFAULT_PROXY : WINHTTP_ACCESS_TYPE_NO_PROXY; #endif const char* proxyHosts = nullptr;