本文整理汇总了C++中Proxy::setProxyURL方法的典型用法代码示例。如果您正苦于以下问题:C++ Proxy::setProxyURL方法的具体用法?C++ Proxy::setProxyURL怎么用?C++ Proxy::setProxyURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Proxy
的用法示例。
在下文中一共展示了Proxy::setProxyURL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getautoproxy
Proxy* WinHttpIO::getautoproxy()
{
Proxy* proxy = new Proxy();
proxy->setProxyType(Proxy::NONE);
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieProxyConfig = { 0 };
if (WinHttpGetIEProxyConfigForCurrentUser(&ieProxyConfig) == TRUE)
{
if (ieProxyConfig.lpszProxy)
{
string proxyURL;
proxy->setProxyType(Proxy::CUSTOM);
int len = wcslen(ieProxyConfig.lpszProxy);
proxyURL.assign((const char*)ieProxyConfig.lpszProxy, len * sizeof(wchar_t) + 1);
// only save one proxy
for (int i = 0; i < len; i++)
{
wchar_t* character = (wchar_t*)(proxyURL.data() + i * sizeof(wchar_t));
if (*character == ' ' || *character == ';')
{
proxyURL.resize(i*sizeof(wchar_t));
len = i;
break;
}
}
// remove protocol prefix, if any
for (int i = len - 1; i >= 0; i--)
{
wchar_t* character = (wchar_t*)(proxyURL.data() + i * sizeof(wchar_t));
if (*character == '/')
{
proxyURL = proxyURL.substr((i + 1) * sizeof(wchar_t));
break;
}
}
proxy->setProxyURL(&proxyURL);
}
else if (ieProxyConfig.lpszAutoConfigUrl || ieProxyConfig.fAutoDetect == TRUE)
{
WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions;
if (ieProxyConfig.lpszAutoConfigUrl)
{
autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
autoProxyOptions.lpszAutoConfigUrl = ieProxyConfig.lpszAutoConfigUrl;
autoProxyOptions.dwAutoDetectFlags = 0;
}
else
{
autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
autoProxyOptions.lpszAutoConfigUrl = NULL;
autoProxyOptions.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A;
}
autoProxyOptions.fAutoLogonIfChallenged = TRUE;
autoProxyOptions.lpvReserved = NULL;
autoProxyOptions.dwReserved = 0;
WINHTTP_PROXY_INFO proxyInfo;
if (WinHttpGetProxyForUrl(hSession, L"https://g.api.mega.co.nz/", &autoProxyOptions, &proxyInfo))
{
if (proxyInfo.lpszProxy)
{
string proxyURL;
proxy->setProxyType(Proxy::CUSTOM);
proxyURL.assign((const char*)proxyInfo.lpszProxy, wcslen(proxyInfo.lpszProxy) * sizeof(wchar_t));
proxy->setProxyURL(&proxyURL);
}
}
}
}
if (ieProxyConfig.lpszProxy)
{
GlobalFree(ieProxyConfig.lpszProxy);
}
if (ieProxyConfig.lpszProxyBypass)
{
GlobalFree(ieProxyConfig.lpszProxyBypass);
}
if (ieProxyConfig.lpszAutoConfigUrl)
{
GlobalFree(ieProxyConfig.lpszAutoConfigUrl);
}
return proxy;
}