+32
-34
lines changedFilter options
+32
-34
lines changed Original file line number Diff line number Diff line change
@@ -10,10 +10,6 @@
10
10
****/
11
11
#pragma once
12
12
13
-
#ifdef _WIN32
14
-
#include <Windows.h>
15
-
#endif // _WIN32
16
-
17
13
#include "cpprest/asyncrt_utils.h"
18
14
#include "cpprest/uri.h"
19
15
Original file line number Diff line number Diff line change
@@ -243,6 +243,24 @@ enum msg_body_type
243
243
transfer_encoding_chunked
244
244
};
245
245
246
+
static DWORD WinHttpDefaultProxyConstant() CPPREST_NOEXCEPT
247
+
{
248
+
#if _WIN32_WINNT >= _WIN32_WINNT_VISTA
249
+
#if _WIN32_WINNT < _WIN32_WINNT_WINBLUE
250
+
if (!IsWindows8Point1OrGreater())
251
+
{
252
+
// Not Windows 8.1 or later, use the default proxy setting
253
+
return WINHTTP_ACCESS_TYPE_DEFAULT_PROXY;
254
+
}
255
+
#endif // _WIN32_WINNT < _WIN32_WINNT_WINBLUE
256
+
257
+
// Windows 8.1 or later, use the automatic proxy setting
258
+
return WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY;
259
+
#else // ^^^ _WIN32_WINNT >= _WIN32_WINNT_VISTA ^^^ // vvv _WIN32_WINNT < _WIN32_WINNT_VISTA vvv
260
+
return WINHTTP_ACCESS_TYPE_DEFAULT_PROXY;
261
+
#endif // _WIN32_WINNT >= _WIN32_WINNT_VISTA
262
+
}
263
+
246
264
// Additional information necessary to track a WinHTTP request.
247
265
class winhttp_request_context final : public request_context
248
266
{
@@ -818,38 +836,30 @@ class winhttp_client final : public _http_client_communicator
818
836
ie_proxy_config proxyIE;
819
837
820
838
DWORD access_type;
821
-
LPCWSTR proxy_name;
839
+
LPCWSTR proxy_name = WINHTTP_NO_PROXY_NAME;
822
840
LPCWSTR proxy_bypass = WINHTTP_NO_PROXY_BYPASS;
841
+
m_proxy_auto_config = false;
823
842
utility::string_t proxy_str;
824
843
http::uri uri;
825
844
826
845
const auto& config = client_config();
827
-
828
-
if (config.proxy().is_disabled())
846
+
const auto& proxy = config.proxy();
847
+
if (proxy.is_default())
848
+
{
849
+
access_type = WinHttpDefaultProxyConstant();
850
+
}
851
+
else if (proxy.is_disabled())
829
852
{
830
853
access_type = WINHTTP_ACCESS_TYPE_NO_PROXY;
831
-
proxy_name = WINHTTP_NO_PROXY_NAME;
832
854
}
833
-
else if (config.proxy().is_default() || config.proxy().is_auto_discovery())
855
+
else if (proxy.is_auto_discovery())
834
856
{
835
-
// Use the default WinHTTP proxy by default.
836
-
access_type = WINHTTP_ACCESS_TYPE_DEFAULT_PROXY;
837
-
proxy_name = WINHTTP_NO_PROXY_NAME;
838
-
839
-
#if _WIN32_WINNT < _WIN32_WINNT_VISTA
840
-
if (config.proxy().is_auto_discovery())
857
+
access_type = WinHttpDefaultProxyConstant();
858
+
if (access_type != WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY)
841
859
{
860
+
// Windows 8 or earlier, do proxy autodetection ourselves
842
861
m_proxy_auto_config = true;
843
-
}
844
-
#else // ^^^ _WIN32_WINNT < _WIN32_WINNT_VISTA ^^^ // vvv _WIN32_WINNT >= _WIN32_WINNT_VISTA vvv
845
-
if (IsWindows8Point1OrGreater())
846
-
{
847
-
// Windows 8.1 and newer supports automatic proxy discovery and auto-fallback to IE proxy settings
848
-
access_type = WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY;
849
-
}
850
-
else
851
-
{
852
-
// However, if it is not configured...
862
+
853
863
proxy_info proxyDefault;
854
864
if (!WinHttpGetDefaultProxyConfiguration(&proxyDefault) ||
855
865
proxyDefault.dwAccessType == WINHTTP_ACCESS_TYPE_NO_PROXY)
@@ -881,13 +891,7 @@ class winhttp_client final : public _http_client_communicator
881
891
}
882
892
}
883
893
}
884
-
885
-
if (config.proxy().is_auto_discovery())
886
-
{
887
-
m_proxy_auto_config = true;
888
-
}
889
894
}
890
-
#endif // _WIN32_WINNT < _WIN32_WINNT_VISTA
891
895
}
892
896
else
893
897
{
@@ -1007,9 +1011,7 @@ class winhttp_client final : public _http_client_communicator
1007
1011
1008
1012
if (m_proxy_auto_config)
1009
1013
{
1010
-
WINHTTP_AUTOPROXY_OPTIONS autoproxy_options;
1011
-
memset(&autoproxy_options, 0, sizeof(WINHTTP_AUTOPROXY_OPTIONS));
1012
-
1014
+
WINHTTP_AUTOPROXY_OPTIONS autoproxy_options {};
1013
1015
if (m_proxy_auto_config_url.empty())
1014
1016
{
1015
1017
autoproxy_options.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4