resolve missing last proxy in proxy detection
This commit is contained in:
@@ -11,11 +11,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <winhttp.h>
|
#include <winhttp.h>
|
||||||
|
|
||||||
#ifdef QT_NETWORK_LIB
|
|
||||||
#include <QtCore/QDebug> // debug
|
|
||||||
#else
|
|
||||||
#include <iostream> // debug
|
#include <iostream> // debug
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace proxy {
|
namespace proxy {
|
||||||
|
|
||||||
@@ -54,14 +50,10 @@ namespace proxy {
|
|||||||
throw exc::error();
|
throw exc::error();
|
||||||
|
|
||||||
std::wstring list(proxyInfo.lpszProxy);
|
std::wstring list(proxyInfo.lpszProxy);
|
||||||
#ifdef QT_NETWORK_LIB
|
|
||||||
qDebug()<<"LIST=\""<<proxyInfo.lpszProxy<<"\"";
|
|
||||||
#else
|
|
||||||
std::wcout<<"LIST=\""<<list<<"\""<<std::endl;
|
std::wcout<<"LIST=\""<<list<<"\""<<std::endl;
|
||||||
#endif
|
|
||||||
for (std::wstring::size_type oldpos(0), pos(0);
|
for (std::wstring::size_type oldpos(0), pos(0);
|
||||||
(pos=list.find(L";", oldpos))!=std::wstring::npos;
|
(pos=list.find(L";", oldpos)), oldpos!=std::wstring::npos;
|
||||||
oldpos=++pos) {
|
oldpos=(pos!=std::wstring::npos?pos+1:pos)) {
|
||||||
std::wstring proxy(list.substr(oldpos, pos-oldpos));
|
std::wstring proxy(list.substr(oldpos, pos-oldpos));
|
||||||
std::wstring port((oldpos=proxy.rfind(L":"))!=std::wstring::npos
|
std::wstring port((oldpos=proxy.rfind(L":"))!=std::wstring::npos
|
||||||
?proxy.substr(oldpos+1):std::wstring());
|
?proxy.substr(oldpos+1):std::wstring());
|
||||||
@@ -72,9 +64,10 @@ namespace proxy {
|
|||||||
case WINHTTP_ACCESS_TYPE_DEFAULT_PROXY: type=DEFAULT; break;
|
case WINHTTP_ACCESS_TYPE_DEFAULT_PROXY: type=DEFAULT; break;
|
||||||
case WINHTTP_ACCESS_TYPE_NAMED_PROXY: type=HTTP; break;
|
case WINHTTP_ACCESS_TYPE_NAMED_PROXY: type=HTTP; break;
|
||||||
}
|
}
|
||||||
res.push_back(Proxy(type,
|
if (host.size()>0)
|
||||||
std::string(host.begin(), host.end()),
|
res.push_back(Proxy(type,
|
||||||
std::string(port.begin(), port.end())));
|
std::string(host.begin(), host.end()),
|
||||||
|
std::string(port.begin(), port.end())));
|
||||||
}
|
}
|
||||||
if (!res.size()) res.push_back(Proxy());
|
if (!res.size()) res.push_back(Proxy());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user