diff options
author | Mårten Nordheim <morten242@gmail.com> | 2020-06-12 12:07:54 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2020-06-15 12:29:19 +0200 |
commit | a0bfa4e1f8e223927cbb285bb17d1a00a5c2d4b6 (patch) | |
tree | 70485146b53954db668c093050cc5a829d56f2b1 | |
parent | 6be9830d865be32f224e15d13ddefd9c7e176553 (diff) |
QNAM: Remove network connectivity pre-check
The connectivity pre-check has been around for a long time, and it has
caused various issues in that time. Certain scenarios, like using
certain VPN configurations, might confuse the OS into thinking you don't
have and network connectivity at all and abort the connection.
Especially noticeable/frustrating when the connection was going to a
host inside the local network.
The negative impact of this change would at worst be that we might try
to connect and it will wait some amount of time before the OS tells us
the connection failed in situations where it would previously have been
aborted before it started. But the false-negatives are not really an OK
sacrifice in that case.
Fixes: QTBUG-84907
Change-Id: I37fc69051e39df3c1a1fecb56ef54521a4d3d0c3
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 32 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager.h | 1 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager_p.h | 4 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl.cpp | 25 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyimpl_p.h | 14 |
5 files changed, 0 insertions, 76 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index ea05514932..8bc0159b9d 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -422,14 +422,6 @@ QNetworkAccessManager::QNetworkAccessManager(QObject *parent) #endif qRegisterMetaType<QNetworkReply::NetworkError>(); qRegisterMetaType<QSharedPointer<char> >(); - - Q_D(QNetworkAccessManager); - - if (QNetworkStatusMonitor::isEnabled()) { - connect(&d->statusMonitor, SIGNAL(onlineStateChanged(bool)), - SLOT(_q_onlineStateChanged(bool))); - d->networkAccessible = d->statusMonitor.isNetworkAccessible(); - } } /*! @@ -1199,25 +1191,6 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera return reply; } } - - if (d->statusMonitor.isEnabled()) { - if (!d->statusMonitor.isMonitoring() && !d->statusMonitor.start()) - qWarning(lcNetMon, "failed to start network status monitoring"); - - // See the code in ctor - QNetworkStatusMonitor allows us to - // immediately set 'networkAccessible' even before we start - // the monitor. If the monitor is unable to monitor then let's - // assume there's something wrong with the monitor and keep going. - if (d->statusMonitor.isMonitoring() && !d->networkAccessible && !isLocalFile) { - QHostAddress dest; - QString host = req.url().host().toLower(); - if (!(dest.setAddress(host) && dest.isLoopback()) - && host != QLatin1String("localhost") - && host != QHostInfo::localHostName().toLower()) { - return new QDisabledNetworkReply(this, req, op); - } - } - } #endif QNetworkRequest request = req; if (!request.header(QNetworkRequest::ContentLengthHeader).isValid() && @@ -1676,11 +1649,6 @@ void QNetworkAccessManagerPrivate::destroyThread() } } -void QNetworkAccessManagerPrivate::_q_onlineStateChanged(bool isOnline) -{ - networkAccessible = isOnline; -} - #if QT_CONFIG(http) QNetworkRequest QNetworkAccessManagerPrivate::prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart) { diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h index cbc9a0b660..db76d6daf1 100644 --- a/src/network/access/qnetworkaccessmanager.h +++ b/src/network/access/qnetworkaccessmanager.h @@ -182,7 +182,6 @@ private: #ifndef QT_NO_SSL Q_PRIVATE_SLOT(d_func(), void _q_replyPreSharedKeyAuthenticationRequired(QSslPreSharedKeyAuthenticator*)) #endif - Q_PRIVATE_SLOT(d_func(), void _q_onlineStateChanged(bool)) }; QT_END_NAMESPACE diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h index e0f4d19d6f..bda946042c 100644 --- a/src/network/access/qnetworkaccessmanager_p.h +++ b/src/network/access/qnetworkaccessmanager_p.h @@ -126,8 +126,6 @@ public: QNetworkAccessBackend *findBackend(QNetworkAccessManager::Operation op, const QNetworkRequest &request); QStringList backendSupportedSchemes() const; - void _q_onlineStateChanged(bool isOnline); - #if QT_CONFIG(http) QNetworkRequest prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart); #endif @@ -145,8 +143,6 @@ public: QNetworkProxyFactory *proxyFactory; #endif - bool networkAccessible = true; - bool cookieJarCreated; bool defaultAccessControl; QNetworkRequest::RedirectPolicy redirectPolicy; diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp index bc6bc53610..ecffc7131e 100644 --- a/src/network/access/qnetworkreplyimpl.cpp +++ b/src/network/access/qnetworkreplyimpl.cpp @@ -910,31 +910,6 @@ bool QNetworkReplyImpl::event(QEvent *e) return QObject::event(e); } -QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent, - const QNetworkRequest &req, - QNetworkAccessManager::Operation op) -: QNetworkReply(parent) -{ - setRequest(req); - setUrl(req.url()); - setOperation(op); - setFinished(true); - - qRegisterMetaType<QNetworkReply::NetworkError>(); - - QString msg = QCoreApplication::translate("QNetworkAccessManager", - "Network access is disabled."); - setError(UnknownNetworkError, msg); - - QMetaObject::invokeMethod(this, "errorOccurred", Qt::QueuedConnection, - Q_ARG(QNetworkReply::NetworkError, UnknownNetworkError)); - QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); -} - -QDisabledNetworkReply::~QDisabledNetworkReply() -{ -} - QT_END_NAMESPACE #include "moc_qnetworkreplyimpl_p.cpp" diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h index d5b67d4c9c..bb5afe49d6 100644 --- a/src/network/access/qnetworkreplyimpl_p.h +++ b/src/network/access/qnetworkreplyimpl_p.h @@ -191,20 +191,6 @@ public: }; Q_DECLARE_TYPEINFO(QNetworkReplyImplPrivate::InternalNotifications, Q_PRIMITIVE_TYPE); -class QDisabledNetworkReply : public QNetworkReply -{ - Q_OBJECT - -public: - QDisabledNetworkReply(QObject *parent, const QNetworkRequest &req, - QNetworkAccessManager::Operation op); - ~QDisabledNetworkReply(); - - void abort() override { } -protected: - qint64 readData(char *, qint64) override { return -1; } -}; - QT_END_NAMESPACE Q_DECLARE_METATYPE(QSharedPointer<char>) |