summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp1
-rw-r--r--src/network/access/qhttpnetworkreply.cpp5
-rw-r--r--src/network/access/qhttpnetworkreply_p.h3
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp6
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp23
-rw-r--r--src/network/access/qnetworkaccessmanager.h2
-rw-r--r--src/network/access/qnetworkrequest.cpp6
-rw-r--r--src/network/access/qnetworkrequest.h4
-rw-r--r--src/network/doc/src/network-programming.qdoc25
-rw-r--r--src/network/doc/src/qtnetwork.qdoc1
-rw-r--r--src/network/kernel/qnetconmonitor_win.cpp38
-rw-r--r--src/network/socket/qabstractsocket.cpp7
-rw-r--r--src/network/socket/qlocalsocket.cpp2
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp3
14 files changed, 57 insertions, 69 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index a3c8172a70..65c2ae3054 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -1098,6 +1098,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 1ba52ac6d6..78413062b4 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 82128f656e..4638d056de 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;
@@ -255,6 +257,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 5a0940aa24..fa03bf7a11 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -417,6 +417,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 38807d3cda..85f065223a 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -220,27 +220,6 @@ static void ensureInitialized()
can be:
\snippet code/src_network_access_qnetworkaccessmanager.cpp 1
- \section1 Network and Roaming Support
-
- With the addition of the \l {Bearer Management} API to Qt 4.7
- QNetworkAccessManager gained the ability to manage network connections.
- QNetworkAccessManager can start the network interface if the device is
- offline and terminates the interface if the current process is the last
- one to use the uplink. Note that some platforms utilize grace periods from
- when the last application stops using a uplink until the system actually
- terminates the connectivity link. Roaming is equally transparent. Any
- queued/pending network requests are automatically transferred to the new
- access point.
-
- Clients wanting to utilize this feature should not require any changes. In fact
- it is likely that existing platform specific connection code can simply be
- removed from the application.
-
- \note The network and roaming support in QNetworkAccessManager is conditional
- upon the platform supporting connection management. The
- \l QNetworkConfigurationManager::NetworkSessionRequired can be used to
- detect whether QNetworkAccessManager utilizes this feature.
-
\sa QNetworkRequest, QNetworkReply, QNetworkProxy
*/
@@ -1475,7 +1454,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/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h
index cfb75f0f90..5194afb1be 100644
--- a/src/network/access/qnetworkaccessmanager.h
+++ b/src/network/access/qnetworkaccessmanager.h
@@ -170,7 +170,7 @@ public:
void setAutoDeleteReplies(bool autoDelete);
int transferTimeout() const;
- void setTransferTimeout(int timeout = QNetworkRequest::TransferTimeoutPreset);
+ void setTransferTimeout(int timeout = QNetworkRequest::DefaultTransferTimeoutConstant);
Q_SIGNALS:
#ifndef QT_NO_NETWORKPROXY
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index 473aa42e1e..4765fdc30e 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -414,9 +414,9 @@ QT_BEGIN_NAMESPACE
A constant that can be used for enabling transfer
timeouts with a preset value.
- \value TransferTimeoutPreset The transfer timeout in milliseconds.
- Used if setTimeout() is called
- without an argument.
+ \value DefaultTransferTimeoutConstant The transfer timeout in milliseconds.
+ Used if setTimeout() is called
+ without an argument.
*/
class QNetworkRequestPrivate: public QSharedData, public QNetworkHeadersPrivate
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h
index cb15ca5aa5..035b5b378a 100644
--- a/src/network/access/qnetworkrequest.h
+++ b/src/network/access/qnetworkrequest.h
@@ -127,7 +127,7 @@ public:
};
enum TransferTimeoutConstant {
- TransferTimeoutPreset = 30000
+ DefaultTransferTimeoutConstant = 30000
};
QNetworkRequest();
@@ -182,7 +182,7 @@ public:
void setHttp2Configuration(const QHttp2Configuration &configuration);
int transferTimeout() const;
- void setTransferTimeout(int timeout = TransferTimeoutPreset);
+ void setTransferTimeout(int timeout = DefaultTransferTimeoutConstant);
#endif // QT_CONFIG(http) || defined(Q_CLANG_QDOC)
private:
QSharedDataPointer<QNetworkRequestPrivate> d;
diff --git a/src/network/doc/src/network-programming.qdoc b/src/network/doc/src/network-programming.qdoc
index ce99af034b..654227f971 100644
--- a/src/network/doc/src/network-programming.qdoc
+++ b/src/network/doc/src/network-programming.qdoc
@@ -261,29 +261,4 @@
by passing a factory to QNetworkProxyFactory::setApplicationProxyFactory()
and a custom proxying policy can be created by subclassing
QNetworkProxyFactory; see the class documentation for details.
-
- \section1 Bearer Management Support
-
- Bearer Management controls the connectivity state of the device such that
- the application can start or stop network interfaces and roam
- transparently between access points.
-
- The QNetworkConfigurationManager class manages the list of network
- configurations known to the device. A network configuration describes the
- set of parameters used to start a network interface and is represented by
- the QNetworkConfiguration class.
-
- A network interface is started by openning a QNetworkSession based on a
- given network configuration. In most situations creating a network session
- based on the platform specified default network configuration is
- appropriate. The default network configuration is returned by the
- QNetworkConfigurationManager::defaultConfiguration() function.
-
- On some platforms it is a platform requirement that the application open a
- network session before any network operations can be performed. This can be
- tested by the presents of the
- QNetworkConfigurationManager::NetworkSessionRequired flag in the value
- returned by the QNetworkConfigurationManager::capabilities() function.
-
- \sa {Bearer Management}
*/
diff --git a/src/network/doc/src/qtnetwork.qdoc b/src/network/doc/src/qtnetwork.qdoc
index c931a1c19f..85a3c198a0 100644
--- a/src/network/doc/src/qtnetwork.qdoc
+++ b/src/network/doc/src/qtnetwork.qdoc
@@ -54,7 +54,6 @@
applications with networking capabilities.
\list
\li \l{Network Programming with Qt} - Programming applications with networking capabilities
- \li \l{Bearer Management} - An API to control the system's connectivity state
\li \l{Secure Sockets Layer (SSL) Classes} - Classes for secure communication over network sockets
\endlist
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/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 3d88c0337d..5f1ff2fcb8 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -1465,13 +1465,8 @@ QAbstractSocket::QAbstractSocket(SocketType socketType,
\sa socketType(), QTcpSocket, QUdpSocket
*/
QAbstractSocket::QAbstractSocket(SocketType socketType, QObject *parent)
- : QIODevice(*new QAbstractSocketPrivate, parent)
+ : QAbstractSocket(socketType, *new QAbstractSocketPrivate, parent)
{
- Q_D(QAbstractSocket);
-#if defined(QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocket::QAbstractSocket(%p)", parent);
-#endif
- d->socketType = socketType;
}
/*!
diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp
index 38e47d6e26..18f400fe0b 100644
--- a/src/network/socket/qlocalsocket.cpp
+++ b/src/network/socket/qlocalsocket.cpp
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
On Windows this is a named pipe and on Unix this is a local domain socket.
- If an error occurs, socketError() returns the type of error, and
+ If an error occurs, error() returns the type of error, and
errorString() can be called to get a human readable description
of what happened.
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) {