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>bb10
parent
6be9830d86
commit
a0bfa4e1f8
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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>)
|
||||
|
|
|
|||
Loading…
Reference in New Issue