summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkreplyhttpimpl.cpp
diff options
context:
space:
mode:
authorJesus Fernandez <jesus.fernandez@theqtcompany.com>2016-02-15 17:18:12 +0100
committerEdward Welbourne <edward.welbourne@theqtcompany.com>2016-03-07 18:07:37 +0000
commit8c86d57e3268872150d0741ee4edf243b20a4400 (patch)
treedf204c63ee642759b3b3985bec5b3832292d3ea9 /src/network/access/qnetworkreplyhttpimpl.cpp
parent95ea7552a1c7dc353d6dd4af9d2baaf8f2436c64 (diff)
Async open file support in QNetworkAccessManager
This change adds support for BackgroundRequestAttribute to local file request. It is useful when opening files located in network drives where the file open operation could take several seconds to complete. When this attribute is activated the QNetworkAccessManager::get call returns the reply immediately and the user has to wait until QNetworkReply::finished signal is emitted or QNetworkReply::isFinished function returns true. Task-number: QTBUG-45925 Change-Id: Ie2019dd94fe04253d1ef6874811d7e749a5aad93 Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Diffstat (limited to 'src/network/access/qnetworkreplyhttpimpl.cpp')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index f9547e1508..9e39315268 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -617,17 +617,10 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
thread->setObjectName(QStringLiteral("Qt HTTP synchronous thread"));
QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
- } else if (!managerPrivate->httpThread) {
+ } else {
// We use the manager-global thread.
// At some point we could switch to having multiple threads if it makes sense.
- managerPrivate->httpThread = new QThread();
- managerPrivate->httpThread->setObjectName(QStringLiteral("Qt HTTP thread"));
- managerPrivate->httpThread->start();
-
- thread = managerPrivate->httpThread;
- } else {
- // Asynchronous request, thread already exists
- thread = managerPrivate->httpThread;
+ thread = managerPrivate->createThread();
}
QUrl url = newHttpRequest.url();
@@ -1139,8 +1132,8 @@ void QNetworkReplyHttpImplPrivate::onRedirected(const QUrl &redirectUrl, int htt
cookedHeaders.clear();
- if (managerPrivate->httpThread)
- managerPrivate->httpThread->disconnect();
+ if (managerPrivate->thread)
+ managerPrivate->thread->disconnect();
// Recurse
QMetaObject::invokeMethod(q, "start", Qt::QueuedConnection,