我正在使用 Casablanca C++ REST SDK 来执行 Web 请求,但是我希望代码足够智能以检测任何系统代理设置。在 C# 中,我相信这很简单:
WebRequest.DefaultProxy = WebRequest.GetSystemWebProxy();
但是如何使用 REST SDK 库在 C++ 中进行等效操作?到目前为止,我有以下代码,但它需要手动设置代理信息:
http_client_config config;
// Set proxy information if it's enabled
if (_bClientProxyEnabled)
{
config.set_proxy(web::web_proxy(web::uri(utility::conversions::to_string_t(_sClientProxyServer))));
credentials cred(utility::conversions::to_string_t(_sClientProxyUsername),
utility::conversions::to_string_t(_sClientProxyPassword));
// Set credentials
config.set_credentials(cred);
}
http_client client(utility::conversions::to_string_t(this->serverUrl.c_str()), config);
// Build request URI and start the request.
uri_builder builder(utility::conversions::to_string_t(serverEndpoint));
关于如何使此代码自动检测默认系统代理的任何想法?