summaryrefslogtreecommitdiffstats
path: root/src/network/kernel
diff options
context:
space:
mode:
authorArvid Ephraim Picciani <arvid.picciani@nokia.com>2011-10-24 14:41:44 (GMT)
committerPeter Hartmann <peter.hartmann@nokia.com>2011-11-17 10:26:17 (GMT)
commit2ec828a2baa35725bedb56a2611e817a6c2d875e (patch)
tree71edeb259126301ae6c0f1ceb8fb9eb1eadc8b78 /src/network/kernel
parented4d47fde11bf1bded55394358b19ceedb1d5768 (diff)
downloadQt-2ec828a2baa35725bedb56a2611e817a6c2d875e.zip
Qt-2ec828a2baa35725bedb56a2611e817a6c2d875e.tar.gz
Qt-2ec828a2baa35725bedb56a2611e817a6c2d875e.tar.bz2
QNAM: make systemProxyForQuery respect http_proxy
the generic systemProxyForQuery will use http_proxy from the environment, if it is set. Change-Id: Ie685c47eb6df1fdd2ab223defc7172bb25e6fe30 Reviewed-by: Thiago Macieira (Intel) <thiago.macieira@intel.com> (cherry picked from commit b22d290a37903f2c5ecfe58e8183cd293ead99dc)
Diffstat (limited to 'src/network/kernel')
-rw-r--r--src/network/kernel/qnetworkproxy_generic.cpp31
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