C ++ REST SDK(Casablanca) - 如何获取HTTP代理设置

时间:2017-06-02 20:15:04

标签: c++ cpprest-sdk

我正在使用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));

有关如何使此代码自动检测默认系统代理的任何想法?

0 个答案:

没有答案