diff options
author | Julien Brianceau <jbrianceau@nds.com> | 2012-09-05 11:45:23 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-09-07 21:55:21 (GMT) |
commit | 373df03b86c838b1260dc2d7810c3c1556f01eaa (patch) | |
tree | 2ec0649d37a12f7e5b4dcd815dd48c94c5ce59d8 /src/network | |
parent | 24dae5e17fa078c8c301c13456d67e826d97564e (diff) | |
download | Qt-373df03b86c838b1260dc2d7810c3c1556f01eaa.zip Qt-373df03b86c838b1260dc2d7810c3c1556f01eaa.tar.gz Qt-373df03b86c838b1260dc2d7810c3c1556f01eaa.tar.bz2 |
QtNetwork: bypass proxy for local connections
According to Qt doc, "Network proxy is not used if the address used in
connectToHost(), bind() or listen() is equivalent to
QHostAddress::LocalHost or QHostAddress::LocalHostIPv6. This is not the
case in current implementation.
cherry-picked from qt5/qtbase commit 5b1bc864a91c3bdb02e36e7546dadebabb42fdec
Change-Id: I20585b4be1149f67f77f02903aac53ee8b140eab
Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/kernel/qnetworkproxy.cpp | 13 | ||||
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 10 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp index a01c853..e862b17 100644 --- a/src/network/kernel/qnetworkproxy.cpp +++ b/src/network/kernel/qnetworkproxy.cpp @@ -302,6 +302,19 @@ QList<QNetworkProxy> QGlobalNetworkProxy::proxyForQuery(const QNetworkProxyQuery QMutexLocker locker(&mutex); QList<QNetworkProxy> result; + + // don't look for proxies for a local connection + QHostAddress parsed; + QString hostname = query.url().host(); + if (hostname == QLatin1String("localhost") + || hostname.startsWith(QLatin1String("localhost.")) + || (parsed.setAddress(hostname) + && (parsed == QHostAddress::LocalHost + || parsed == QHostAddress::LocalHostIPv6))) { + result << QNetworkProxy(QNetworkProxy::NoProxy); + return result; + } + if (!applicationLevelProxyFactory) { if (applicationLevelProxy && applicationLevelProxy->type() != QNetworkProxy::DefaultProxy) diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 8407271..36049a3 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -800,16 +800,6 @@ bool QAbstractSocketPrivate::flush() */ void QAbstractSocketPrivate::resolveProxy(const QString &hostname, quint16 port) { - QHostAddress parsed; - if (hostname == QLatin1String("localhost") - || hostname.startsWith(QLatin1String("localhost.")) - || (parsed.setAddress(hostname) - && (parsed == QHostAddress::LocalHost - || parsed == QHostAddress::LocalHostIPv6))) { - proxyInUse = QNetworkProxy::NoProxy; - return; - } - QList<QNetworkProxy> proxies; if (proxy.type() != QNetworkProxy::DefaultProxy) { |