From 7430d3f321b34a8a11470c55a2af1872a806726e Mon Sep 17 00:00:00 2001 From: Adrien Bustany Date: Wed, 25 Apr 2012 14:23:01 +0300 Subject: QNetworkProxyFactory: check all the proxy environment variables QNetworkProxyFactory used to check only for the http_proxy environment variable in systemProxyForQuery. This patch makes it look as well in https_proxy, ftp_proxy and all_proxy. http_proxy is still used as a fallback value. Change-Id: I7934af70d191cd17dbce3b3789260ae1a8332986 (cherry-picked from qtbase commit a7d1b6419d7503474ed5e02f7fb984e4ad5f9219) Reviewed-by: Shane Kearns --- src/network/kernel/qnetworkproxy_generic.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/network/kernel/qnetworkproxy_generic.cpp b/src/network/kernel/qnetworkproxy_generic.cpp index 485f745..d6681b0 100644 --- a/src/network/kernel/qnetworkproxy_generic.cpp +++ b/src/network/kernel/qnetworkproxy_generic.cpp @@ -53,11 +53,26 @@ QT_BEGIN_NAMESPACE -QList QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &) +QList QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &query) { QList proxyList; - QByteArray proxy_env = qgetenv("http_proxy"); + const QString queryProtocol = query.protocolTag().toLower(); + QByteArray proxy_env; + + if (queryProtocol == QLatin1String("http")) + proxy_env = qgetenv("http_proxy"); + else if (queryProtocol == QLatin1String("https")) + proxy_env = qgetenv("https_proxy"); + else if (queryProtocol == QLatin1String("ftp")) + proxy_env = qgetenv("ftp_proxy"); + else + proxy_env = qgetenv("all_proxy"); + + // Fallback to http_proxy is no protocol specific proxy was found + if (proxy_env.isEmpty()) + proxy_env = qgetenv("http_proxy"); + if (!proxy_env.isEmpty()) { QUrl url = QUrl(QString::fromLocal8Bit(proxy_env)); if (url.scheme() == QLatin1String("socks5")) { -- cgit v0.12