File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
Release/samples/BingRequest Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -26,18 +26,22 @@ web::http::client::http_client_config client_config_for_proxy()
26
26
{
27
27
web::http::client::http_client_config client_config;
28
28
#ifdef _WIN32
29
- wchar_t * pValue;
30
- size_t len;
29
+ wchar_t * pValue = nullptr ;
30
+ std::unique_ptr<wchar_t , void (*)(wchar_t *)> holder (nullptr , [](wchar_t * p) { free (p); });
31
+ size_t len = 0 ;
31
32
auto err = _wdupenv_s (&pValue, &len, L" http_proxy" );
32
- if (!err) {
33
- std::unique_ptr<wchar_t , void (*)(wchar_t *)> holder (pValue, [](wchar_t * p) { free (p); });
34
- uri proxy_uri (std::wstring (pValue, len));
33
+ if (pValue)
34
+ holder.reset (pValue);
35
+ if (!err && pValue && len) {
36
+ std::wstring env_http_proxy_string (pValue, len - 1 );
35
37
#else
36
38
if (const char * env_http_proxy = std::getenv (" http_proxy" )) {
37
- uri proxy_uri ( utility::conversions::to_string_t (env_http_proxy) );
39
+ std::string env_http_proxy_string (env_http_proxy);
38
40
#endif
39
- web::web_proxy proxy (proxy_uri);
40
- client_config.set_proxy (proxy);
41
+ if (env_http_proxy_string == U (" auto" ))
42
+ client_config.set_proxy (web::web_proxy::use_auto_discovery);
43
+ else
44
+ client_config.set_proxy (web::web_proxy (env_http_proxy_string));
41
45
}
42
46
43
47
return client_config;
You can’t perform that action at this time.
0 commit comments