diff options
author | Liang Qi <liang.qi@qt.io> | 2020-02-18 09:26:53 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2020-02-18 09:26:53 +0100 |
commit | b9585277e78f0571933706507ba2024c68d6df19 (patch) | |
tree | c98577aae762b75d0ac6437c1ec68da0ddb4426b /src/network | |
parent | eb2af9d923923255b276c6549ada1ed7839d5dd8 (diff) | |
parent | d7b6c4288f2de8b0123c888e83a3fbcd84ed906f (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15
Conflicts:
src/corelib/tools/qlinkedlist.h
src/plugins/platforms/wasm/qwasmintegration.cpp
src/plugins/platforms/wasm/qwasmscreen.cpp
Change-Id: Iefca7f9f4966bdc20e7052aca736874861055738
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 1 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkreply.cpp | 5 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkreply_p.h | 3 | ||||
-rw-r--r-- | src/network/access/qhttpthreaddelegate.cpp | 6 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 2 | ||||
-rw-r--r-- | src/network/kernel/qnetconmonitor_win.cpp | 38 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_win.cpp | 3 |
7 files changed, 49 insertions, 9 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 72af21bd8f..ccdb1cd6cd 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1099,6 +1099,7 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket if (reply) { reply->d_func()->errorString = errorString; + reply->d_func()->httpErrorCode = errorCode; emit reply->finishedWithError(errorCode, errorString); reply = nullptr; if (protocolHandler) diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp index af456c3607..2024c0fefb 100644 --- a/src/network/access/qhttpnetworkreply.cpp +++ b/src/network/access/qhttpnetworkreply.cpp @@ -158,6 +158,11 @@ QString QHttpNetworkReply::errorString() const return d_func()->errorString; } +QNetworkReply::NetworkError QHttpNetworkReply::errorCode() const +{ + return d_func()->httpErrorCode; +} + QString QHttpNetworkReply::reasonPhrase() const { return d_func()->reasonPhrase; diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h index 12cfe359aa..9c03a403e1 100644 --- a/src/network/access/qhttpnetworkreply_p.h +++ b/src/network/access/qhttpnetworkreply_p.h @@ -115,6 +115,8 @@ public: QString errorString() const; void setErrorString(const QString &error); + QNetworkReply::NetworkError errorCode() const; + QString reasonPhrase() const; qint64 bytesAvailable() const; @@ -259,6 +261,7 @@ public: qint64 removedContentLength; QPointer<QHttpNetworkConnection> connection; QPointer<QHttpNetworkConnectionChannel> connectionChannel; + QNetworkReply::NetworkError httpErrorCode = QNetworkReply::NoError; bool autoDecompress; diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp index 7757fb9503..dcc8c9337e 100644 --- a/src/network/access/qhttpthreaddelegate.cpp +++ b/src/network/access/qhttpthreaddelegate.cpp @@ -428,6 +428,12 @@ void QHttpThreadDelegate::startRequest() connect(httpReply, SIGNAL(cacheCredentials(QHttpNetworkRequest,QAuthenticator*)), this, SLOT(cacheCredentialsSlot(QHttpNetworkRequest,QAuthenticator*))); + if (httpReply->errorCode() != QNetworkReply::NoError) { + if (synchronous) + synchronousFinishedWithErrorSlot(httpReply->errorCode(), httpReply->errorString()); + else + finishedWithErrorSlot(httpReply->errorCode(), httpReply->errorString()); + } } // This gets called from the user thread or by the synchronous HTTP timeout timer diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 1120446bc7..7745f4b752 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -1477,7 +1477,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera // immediately set 'networkAccessible' even before we start // the monitor. #ifdef QT_NO_BEARERMANAGEMENT - if (d->networkAccessible + if (!d->networkAccessible #else if (d->networkAccessible == NotAccessible #endif // QT_NO_BEARERMANAGEMENT diff --git a/src/network/kernel/qnetconmonitor_win.cpp b/src/network/kernel/qnetconmonitor_win.cpp index 1566e7f914..59b6cd5b66 100644 --- a/src/network/kernel/qnetconmonitor_win.cpp +++ b/src/network/kernel/qnetconmonitor_win.cpp @@ -163,11 +163,14 @@ private: ComPtr<QNetworkConnectionEvents> connectionEvents; // We can assume we have access to internet/subnet when this class is created because // connection has already been established to the peer: - NLM_CONNECTIVITY connectivity = - NLM_CONNECTIVITY(NLM_CONNECTIVITY_IPV4_INTERNET | NLM_CONNECTIVITY_IPV6_INTERNET - | NLM_CONNECTIVITY_IPV4_SUBNET | NLM_CONNECTIVITY_IPV6_SUBNET); + NLM_CONNECTIVITY connectivity = NLM_CONNECTIVITY( + NLM_CONNECTIVITY_IPV4_INTERNET | NLM_CONNECTIVITY_IPV6_INTERNET + | NLM_CONNECTIVITY_IPV4_SUBNET | NLM_CONNECTIVITY_IPV6_SUBNET + | NLM_CONNECTIVITY_IPV4_LOCALNETWORK | NLM_CONNECTIVITY_IPV6_LOCALNETWORK + | NLM_CONNECTIVITY_IPV4_NOTRAFFIC | NLM_CONNECTIVITY_IPV6_NOTRAFFIC); bool sameSubnet = false; + bool isLinkLocal = false; bool monitoring = false; bool comInitFailed = false; bool remoteIsIPv6 = false; @@ -370,6 +373,7 @@ bool QNetworkConnectionMonitorPrivate::setTargets(const QHostAddress &local, return false; } sameSubnet = remote.isInSubnet(local, it->prefixLength()); + isLinkLocal = remote.isLinkLocal() && local.isLinkLocal(); remoteIsIPv6 = remote.protocol() == QAbstractSocket::IPv6Protocol; return connectionEvents->setTarget(iface); @@ -461,9 +465,28 @@ void QNetworkConnectionMonitor::stopMonitoring() bool QNetworkConnectionMonitor::isReachable() { Q_D(QNetworkConnectionMonitor); - NLM_CONNECTIVITY required = d->sameSubnet - ? (d->remoteIsIPv6 ? NLM_CONNECTIVITY_IPV6_SUBNET : NLM_CONNECTIVITY_IPV4_SUBNET) - : (d->remoteIsIPv6 ? NLM_CONNECTIVITY_IPV6_INTERNET : NLM_CONNECTIVITY_IPV4_INTERNET); + + const NLM_CONNECTIVITY RequiredSameSubnetIPv6 = + NLM_CONNECTIVITY(NLM_CONNECTIVITY_IPV6_SUBNET | NLM_CONNECTIVITY_IPV6_LOCALNETWORK + | NLM_CONNECTIVITY_IPV6_INTERNET); + const NLM_CONNECTIVITY RequiredSameSubnetIPv4 = + NLM_CONNECTIVITY(NLM_CONNECTIVITY_IPV4_SUBNET | NLM_CONNECTIVITY_IPV4_LOCALNETWORK + | NLM_CONNECTIVITY_IPV4_INTERNET); + + NLM_CONNECTIVITY required; + if (d->isLinkLocal) { + required = NLM_CONNECTIVITY( + d->remoteIsIPv6 ? NLM_CONNECTIVITY_IPV6_NOTRAFFIC | RequiredSameSubnetIPv6 + : NLM_CONNECTIVITY_IPV4_NOTRAFFIC | RequiredSameSubnetIPv4); + } else if (d->sameSubnet) { + required = + NLM_CONNECTIVITY(d->remoteIsIPv6 ? RequiredSameSubnetIPv6 : RequiredSameSubnetIPv4); + + } else { + required = NLM_CONNECTIVITY(d->remoteIsIPv6 ? NLM_CONNECTIVITY_IPV6_INTERNET + : NLM_CONNECTIVITY_IPV4_INTERNET); + } + return d_func()->connectivity & required; } @@ -695,7 +718,8 @@ bool QNetworkStatusMonitor::isNetworkAccessible() { return d_func()->connectivity & (NLM_CONNECTIVITY_IPV4_INTERNET | NLM_CONNECTIVITY_IPV6_INTERNET - | NLM_CONNECTIVITY_IPV4_SUBNET | NLM_CONNECTIVITY_IPV6_SUBNET); + | NLM_CONNECTIVITY_IPV4_SUBNET | NLM_CONNECTIVITY_IPV6_SUBNET + | NLM_CONNECTIVITY_IPV4_LOCALNETWORK | NLM_CONNECTIVITY_IPV6_LOCALNETWORK); } bool QNetworkStatusMonitor::isEnabled() diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index dd115c33dc..2581fc048e 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -590,7 +590,8 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters() // local address of the socket which bound on both IPv4 and IPv6 interfaces. // This address does not match to any special address and should not be used // to send the data. So, replace it with QHostAddress::Any. - if (socketProtocol == QAbstractSocket::IPv6Protocol) { + const uchar ipv6MappedNet[] = {0,0,0,0, 0,0,0,0, 0,0,0xff,0xff, 0,0,0,0}; + if (localAddress.isInSubnet(QHostAddress(ipv6MappedNet), 128 - 32)) { bool ok = false; const quint32 localIPv4 = localAddress.toIPv4Address(&ok); if (ok && localIPv4 == INADDR_ANY) { |