Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.11.2, 5.12
-
None
Description
When the QNetworkSocketEngine (e.g. for QTCPSocket) checks if a proxy is used (QNativeSocketEnginePrivate::checkProxy) it passes an incomplete QNetworkProxyQuery to the QNetworkProxyFactory.
This prevents the factory from using different proxy configurations depending on e.g. the peer hostname. For the system proxy on windows it leads to the proxy bypass being ignored, because the peer hostname is required to evaluate the bypass list.
The following code shows the bug.
#include <QCoreApplication> #include <QNetworkProxyFactory> #include <QTcpSocket> #include <QDebug> class MyFactory : public QNetworkProxyFactory { public: virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery & query = QNetworkProxyQuery()) { qDebug() << "Query: " << query.peerHostName() << ":" << query.peerPort(); return QList<QNetworkProxy>() << QNetworkProxy::NoProxy; } }; int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QNetworkProxyFactory::setApplicationProxyFactory(new MyFactory()); QTcpSocket sock; sock.connectToHost("192.0.2.1", 12345); return app.exec(); }
The output is:
Query: "192.0.2.1" : 12345
Query: "" : -1
The first line is originated in QAbstractSocketPrivate::resolveProxy.
The second line in QNativeSocketEngine::connectToHost.
For the second invocation of queryProxy the Query is only initialized with a type, but no hostname or port.