summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp6
-rw-r--r--src/network/access/qnetworkaccessdatabackend.cpp7
-rw-r--r--src/network/access/qnetworkaccessdebugpipebackend.cpp4
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp21
-rw-r--r--src/network/access/qnetworkaccessmanager.h1
-rw-r--r--src/network/access/qnetworkaccessmanager_p.h2
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp2
-rw-r--r--src/network/access/qnetworkreplyimpl_p.h2
8 files changed, 36 insertions, 9 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index e92b2f3..806452c 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -681,7 +681,11 @@ void QHttpNetworkConnectionChannel::requeueCurrentlyPipelinedRequests()
connection->d_func()->requeueRequest(alreadyPipelinedRequests.at(i));
alreadyPipelinedRequests.clear();
- QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
+ // only run when the QHttpNetworkConnection is not currently being destructed, e.g.
+ // this function is called from _q_disconnected which is called because
+ // of ~QHttpNetworkConnectionPrivate
+ if (qobject_cast<QHttpNetworkConnection*>(connection))
+ QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
}
void QHttpNetworkConnectionChannel::eatWhitespace()
diff --git a/src/network/access/qnetworkaccessdatabackend.cpp b/src/network/access/qnetworkaccessdatabackend.cpp
index a2e7ef5..efb6e3e 100644
--- a/src/network/access/qnetworkaccessdatabackend.cpp
+++ b/src/network/access/qnetworkaccessdatabackend.cpp
@@ -44,6 +44,7 @@
#include "qnetworkreply.h"
#include "qurlinfo.h"
#include "private/qdataurl_p.h"
+#include <qcoreapplication.h>
QT_BEGIN_NAMESPACE
@@ -72,7 +73,8 @@ void QNetworkAccessDataBackend::open()
if (operation() != QNetworkAccessManager::GetOperation &&
operation() != QNetworkAccessManager::HeadOperation) {
// data: doesn't support anything but GET
- QString msg = QObject::tr("Operation not supported on %1")
+ const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend",
+ "Operation not supported on %1")
.arg(uri.toString());
error(QNetworkReply::ContentOperationNotPermittedError, msg);
finished();
@@ -96,7 +98,8 @@ void QNetworkAccessDataBackend::open()
}
// something wrong with this URI
- QString msg = QObject::tr("Invalid URI: %1").arg(uri.toString());
+ const QString msg = QCoreApplication::translate("QNetworkAccessDataBackend",
+ "Invalid URI: %1").arg(uri.toString());
error(QNetworkReply::ProtocolFailure, msg);
finished();
}
diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp
index 5926d0b..cd077e7 100644
--- a/src/network/access/qnetworkaccessdebugpipebackend.cpp
+++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp
@@ -252,7 +252,7 @@ void QNetworkAccessDebugPipeBackend::socketError()
break;
}
- error(code, QObject::tr("Socket error on %1: %2")
+ error(code, QNetworkAccessDebugPipeBackend::tr("Socket error on %1: %2")
.arg(url().toString(), socket.errorString()));
finished();
disconnect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
@@ -267,7 +267,7 @@ void QNetworkAccessDebugPipeBackend::socketDisconnected()
// normal close
} else {
// abnormal close
- QString msg = QObject::tr("Remote host closed the connection prematurely on %1")
+ QString msg = QNetworkAccessDebugPipeBackend::tr("Remote host closed the connection prematurely on %1")
.arg(url().toString());
error(QNetworkReply::RemoteHostClosedError, msg);
finished();
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 5876ee2..7bb1399 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -880,11 +880,16 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
return new QDisabledNetworkReply(this, req, op);
}
- if (d->initializeSession && !d->networkSession) {
+ if (!d->networkSession && (d->initializeSession || !d->networkConfiguration.isEmpty())) {
QNetworkConfigurationManager manager;
- d->createSession(manager.defaultConfiguration());
+ if (d->networkConfiguration.isEmpty())
+ d->createSession(manager.defaultConfiguration());
+ else
+ d->createSession(manager.configurationFromIdentifier(d->networkConfiguration));
d->initializeSession = false;
+ } else if (d->networkSession) {
+ d->networkSession->setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), -1);
}
QNetworkRequest request = req;
@@ -943,6 +948,9 @@ void QNetworkAccessManagerPrivate::_q_replyFinished()
QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender());
if (reply)
emit q->finished(reply);
+
+ if (networkSession && q->findChildren<QNetworkReply *>().count() == 1)
+ networkSession->setSessionProperty(QLatin1String("AutoCloseSessionTimeout"), 120000);
}
void QNetworkAccessManagerPrivate::_q_replySslErrors(const QList<QSslError> &errors)
@@ -1210,6 +1218,7 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co
networkSession = new QNetworkSession(config, q);
QObject::connect(networkSession, SIGNAL(opened()), q, SIGNAL(networkSessionOnline()));
+ QObject::connect(networkSession, SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()));
QObject::connect(networkSession, SIGNAL(newConfigurationActivated()),
q, SLOT(_q_networkSessionNewConfigurationActivated()));
QObject::connect(networkSession,
@@ -1218,6 +1227,14 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co
SLOT(_q_networkSessionPreferredConfigurationChanged(QNetworkConfiguration,bool)));
}
+void QNetworkAccessManagerPrivate::_q_networkSessionClosed()
+{
+ networkConfiguration = networkSession->configuration().identifier();
+
+ delete networkSession;
+ networkSession = 0;
+}
+
void QNetworkAccessManagerPrivate::_q_networkSessionNewConfigurationActivated()
{
Q_Q(QNetworkAccessManager);
diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h
index 252dfd0..694a54f 100644
--- a/src/network/access/qnetworkaccessmanager.h
+++ b/src/network/access/qnetworkaccessmanager.h
@@ -139,6 +139,7 @@ private:
Q_DECLARE_PRIVATE(QNetworkAccessManager)
Q_PRIVATE_SLOT(d_func(), void _q_replyFinished())
Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
+ Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed())
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionNewConfigurationActivated())
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionPreferredConfigurationChanged(QNetworkConfiguration,bool))
};
diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h
index 8d772f0..0140268 100644
--- a/src/network/access/qnetworkaccessmanager_p.h
+++ b/src/network/access/qnetworkaccessmanager_p.h
@@ -105,6 +105,7 @@ public:
void createSession(const QNetworkConfiguration &config);
+ void _q_networkSessionClosed();
void _q_networkSessionNewConfigurationActivated();
void _q_networkSessionPreferredConfigurationChanged(const QNetworkConfiguration &config,
bool isSeamless);
@@ -121,6 +122,7 @@ public:
#endif
QNetworkSession *networkSession;
+ QString networkConfiguration;
bool networkAccessEnabled;
bool initializeSession;
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 2175686..b201380 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -565,7 +565,7 @@ void QNetworkReplyImplPrivate::finished()
}
} else {
error(QNetworkReply::TemporaryNetworkFailureError,
- q->tr("Temporary network failure."));
+ QNetworkReply::tr("Temporary network failure."));
}
}
}
diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h
index ec413cc..b4fbd1e 100644
--- a/src/network/access/qnetworkreplyimpl_p.h
+++ b/src/network/access/qnetworkreplyimpl_p.h
@@ -199,7 +199,7 @@ class QDisabledNetworkReply : public QNetworkReply
public:
QDisabledNetworkReply(QObject *parent, const QNetworkRequest &req,
- const QNetworkAccessManager::Operation op);
+ QNetworkAccessManager::Operation op);
~QDisabledNetworkReply();
void abort() { }