diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2011-11-17 10:43:42 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2011-11-17 10:43:42 (GMT) |
commit | 219e320d4cfb49476be74a50c65c515fa8703f0f (patch) | |
tree | dfa999415125ea1b48248a4385785d936fdc31fa /src/network | |
parent | b0d54f150e9b4211e263b4835dd2c64ac07a8c86 (diff) | |
parent | 2ec828a2baa35725bedb56a2611e817a6c2d875e (diff) | |
download | Qt-219e320d4cfb49476be74a50c65c515fa8703f0f.zip Qt-219e320d4cfb49476be74a50c65c515fa8703f0f.tar.gz Qt-219e320d4cfb49476be74a50c65c515fa8703f0f.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging:
QNAM: make systemProxyForQuery respect http_proxy
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/kernel/qnetworkproxy_generic.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/network/kernel/qnetworkproxy_generic.cpp b/src/network/kernel/qnetworkproxy_generic.cpp index e9eaee9..f78f63d 100644 --- a/src/network/kernel/qnetworkproxy_generic.cpp +++ b/src/network/kernel/qnetworkproxy_generic.cpp @@ -41,17 +41,44 @@ #include "qnetworkproxy.h" +#include <QtCore/QByteArray> +#include <QtCore/QUrl> + #ifndef QT_NO_NETWORKPROXY /* - * No system proxy. Just return a list with NoProxy. + * Construct a proxy from the environment variable http_proxy. + * Or no system proxy. Just return a list with NoProxy. */ QT_BEGIN_NAMESPACE QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &) { - return QList<QNetworkProxy>() << QNetworkProxy::NoProxy; + QList<QNetworkProxy> proxyList; + + QByteArray proxy_env = qgetenv("http_proxy"); + if (!proxy_env.isEmpty()) { + QUrl url = QUrl(QString::fromLocal8Bit(proxy_env)); + if (url.scheme() == QLatin1String("socks5")) { + QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(), + url.port() ? url.port() : 1080, url.userName(), url.password()); + proxyList << proxy; + } else if (url.scheme() == QLatin1String("socks5h")) { + QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(), + url.port() ? url.port() : 1080, url.userName(), url.password()); + proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability); + proxyList << proxy; + } else if (url.scheme() == QLatin1String("http") || url.scheme().isEmpty()) { + QNetworkProxy proxy(QNetworkProxy::HttpProxy, url.host(), + url.port() ? url.port() : 8080, url.userName(), url.password()); + proxyList << proxy; + } + } + if (proxyList.isEmpty()) + proxyList << QNetworkProxy::NoProxy; + + return proxyList; } QT_END_NAMESPACE |