summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkaccessmanager.cpp
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2009-11-11 16:13:13 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2009-11-13 10:55:06 (GMT)
commitdbcfac879e8a1ee6ba882585872c5913c131957a (patch)
tree33d04e7e0bbf5219e75ad482e2f5cd92271c1bcf /src/network/access/qnetworkaccessmanager.cpp
parentc66dfc7bf1ae04bdcee9675db95a4787ba4ede69 (diff)
downloadQt-dbcfac879e8a1ee6ba882585872c5913c131957a.zip
Qt-dbcfac879e8a1ee6ba882585872c5913c131957a.tar.gz
Qt-dbcfac879e8a1ee6ba882585872c5913c131957a.tar.bz2
Introduce QFileNetworkReply in QNetworkAccessManager
The QFileNetworkReply is a wrapper around QFile that has therefore similar performance. This avoids the usage of the unperformant QNetworkAccessFileBackend. The benchmark qfile_vs_qnetworkaccessmanager shows that the QFileNetworkReply's performance is better than 0.9x of QFile compared to QNetworkAccessFileBackend which had about 0.5x of QFile. Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network/access/qnetworkaccessmanager.cpp')
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index b1160aa..754633d 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -52,6 +52,7 @@
#include "qnetworkaccessfilebackend_p.h"
#include "qnetworkaccessdatabackend_p.h"
#include "qnetworkaccessdebugpipebackend_p.h"
+#include "qfilenetworkreply_p.h"
#include "QtCore/qbuffer.h"
#include "QtCore/qurl.h"
@@ -681,6 +682,17 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
QIODevice *outgoingData)
{
Q_D(QNetworkAccessManager);
+
+ // fast path for GET on file:// URLs
+ // Also if the scheme is empty we consider it a file.
+ // The QNetworkAccessFileBackend will right now only be used
+ // for PUT or qrc://
+ if (op == QNetworkAccessManager::GetOperation
+ && (req.url().scheme() == QLatin1String("file")
+ || req.url().scheme().isEmpty())) {
+ return new QFileNetworkReply(this, req);
+ }
+
QNetworkRequest request = req;
if (!request.header(QNetworkRequest::ContentLengthHeader).isValid() &&
outgoingData && !outgoingData->isSequential()) {