Windows - fix proxy types for manually specified proxies
When the windows internet options are used to specify a different proxy for each protocol, assume the proxy server type matches that protocol too. e.g. "socks=qt-test-server:1080" is both tagged for socks, and assumed to be a socks server. "ftp=qt-test-server:2121" is assumed to be an ftp proxy "ftp=http://qt-test-server:3128" is overridden to be a http proxy used for ftp. Task-number: QTBUG-10502 Change-Id: I70615c89d6ede53f0e7d62e6d0754b90d042aa2e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
75ab89d4d6
commit
a7489b2ba3
@ -179,38 +179,45 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
|
|||||||
// According to the website, the proxy server list is
|
// According to the website, the proxy server list is
|
||||||
// one or more of the space- or semicolon-separated strings in the format:
|
// one or more of the space- or semicolon-separated strings in the format:
|
||||||
// ([<scheme>=][<scheme>"://"]<server>[":"<port>])
|
// ([<scheme>=][<scheme>"://"]<server>[":"<port>])
|
||||||
|
// The first scheme relates to the protocol tag
|
||||||
|
// The second scheme, if present, overrides the proxy type
|
||||||
|
|
||||||
QList<QNetworkProxy> result;
|
QList<QNetworkProxy> result;
|
||||||
foreach (const QString &entry, proxyList) {
|
foreach (const QString &entry, proxyList) {
|
||||||
int server = 0;
|
int server = 0;
|
||||||
|
|
||||||
|
QNetworkProxy::ProxyType proxyType = QNetworkProxy::HttpProxy;
|
||||||
|
quint16 port = 8080;
|
||||||
|
|
||||||
int pos = entry.indexOf(QLatin1Char('='));
|
int pos = entry.indexOf(QLatin1Char('='));
|
||||||
|
QStringRef scheme;
|
||||||
if (pos != -1) {
|
if (pos != -1) {
|
||||||
QStringRef scheme = entry.leftRef(pos);
|
scheme = entry.leftRef(pos);
|
||||||
if (scheme != query.protocolTag())
|
if (scheme != query.protocolTag())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
server = pos + 1;
|
server = pos + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkProxy::ProxyType proxyType = QNetworkProxy::HttpProxy;
|
|
||||||
quint16 port = 8080;
|
|
||||||
|
|
||||||
pos = entry.indexOf(QLatin1String("://"), server);
|
pos = entry.indexOf(QLatin1String("://"), server);
|
||||||
if (pos != -1) {
|
if (pos != -1) {
|
||||||
QStringRef scheme = entry.midRef(server, pos - server);
|
scheme = entry.midRef(server, pos - server);
|
||||||
|
server = pos + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!scheme.isEmpty()) {
|
||||||
if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) {
|
if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) {
|
||||||
// no-op
|
// no-op
|
||||||
// defaults are above
|
// defaults are above
|
||||||
} else if (scheme == QLatin1String("socks") || scheme == QLatin1String("socks5")) {
|
} else if (scheme == QLatin1String("socks") || scheme == QLatin1String("socks5")) {
|
||||||
proxyType = QNetworkProxy::Socks5Proxy;
|
proxyType = QNetworkProxy::Socks5Proxy;
|
||||||
port = 1080;
|
port = 1080;
|
||||||
|
} else if (scheme == QLatin1String("ftp")) {
|
||||||
|
proxyType = QNetworkProxy::FtpCachingProxy;
|
||||||
|
port = 2121;
|
||||||
} else {
|
} else {
|
||||||
// unknown proxy type
|
// unknown proxy type
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
server = pos + 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = entry.indexOf(QLatin1Char(':'), server);
|
pos = entry.indexOf(QLatin1Char(':'), server);
|
||||||
|
Loading…
Reference in New Issue
Block a user