summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2010-05-10 10:39:52 (GMT)
committerMorten Johan Sørvig <morten.sorvig@nokia.com>2010-05-10 12:27:45 (GMT)
commit0828b63ce77846f14994f7c47468f0db8b42fbd4 (patch)
tree7897439b1720b950e5e13a73c8376d4bb6600238
parentaec71b27ccf4a9513c474bdbe9d65de5fb5fbdc1 (diff)
downloadQt-0828b63ce77846f14994f7c47468f0db8b42fbd4.zip
Qt-0828b63ce77846f14994f7c47468f0db8b42fbd4.tar.gz
Qt-0828b63ce77846f14994f7c47468f0db8b42fbd4.tar.bz2
Revert "Use QUrl::isLocalFile and fix the scheme checking in local URLs."
This reverts commit ebddf7a8739d7f4aaa7d9cb8a41a14eebb65e4f4.
-rw-r--r--src/network/access/qnetworkaccessfilebackend.cpp11
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp11
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp6
3 files changed, 9 insertions, 19 deletions
diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp
index 710c258..4560153 100644
--- a/src/network/access/qnetworkaccessfilebackend.cpp
+++ b/src/network/access/qnetworkaccessfilebackend.cpp
@@ -65,15 +65,10 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op,
}
QUrl url = request.url();
- if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0 || url.isLocalFile()) {
+ if (url.scheme() == QLatin1String("qrc") || !url.toLocalFile().isEmpty())
return new QNetworkAccessFileBackend;
- } else if (!url.scheme().isEmpty() && url.authority().isEmpty()) {
- // check if QFile could, in theory, open this URL via the file engines
- // it has to be in the format:
- // prefix:path/to/file
- // or prefix:/path/to/file
- //
- // this construct here must match the one below in open()
+ else if (!url.isEmpty() && url.authority().isEmpty()) {
+ // check if QFile could, in theory, open this URL
QFileInfo fi(url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery));
if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists()))
return new QNetworkAccessFileBackend;
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 10fdc6f..1c7661d 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -907,20 +907,21 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
{
Q_D(QNetworkAccessManager);
- bool isLocalFile = req.url().isLocalFile();
-
// 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 || op == QNetworkAccessManager::HeadOperation)
- && isLocalFile) {
+ && (req.url().scheme() == QLatin1String("file")
+ || req.url().scheme().isEmpty())) {
return new QFileNetworkReply(this, req, op);
}
#ifndef QT_NO_BEARERMANAGEMENT
// Return a disabled network reply if network access is disabled.
// Except if the scheme is empty or file://.
- if (!d->networkAccessible && !isLocalFile) {
+ if (!d->networkAccessible && !(req.url().scheme() == QLatin1String("file") ||
+ req.url().scheme().isEmpty())) {
return new QDisabledNetworkReply(this, req, op);
}
@@ -962,7 +963,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
QUrl url = request.url();
QNetworkReplyImpl *reply = new QNetworkReplyImpl(this);
#ifndef QT_NO_BEARERMANAGEMENT
- if (!isLocalFile) {
+ if (req.url().scheme() != QLatin1String("file") && !req.url().scheme().isEmpty()) {
connect(this, SIGNAL(networkSessionConnected()),
reply, SLOT(_q_networkSessionConnected()));
}
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index c4d458f..9d942bf 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -1166,12 +1166,6 @@ void tst_QNetworkReply::getErrors_data()
QTest::addColumn<int>("httpStatusCode");
QTest::addColumn<bool>("dataIsEmpty");
- // empties
- QTest::newRow("empty-url") << QString() << int(QNetworkReply::ProtocolUnknownError) << 0 << true;
- QTest::newRow("empty-scheme-host") << SRCDIR "/rfc3252.txt" << int(QNetworkReply::ProtocolUnknownError) << 0 << true;
- QTest::newRow("empty-scheme") << "//" + QtNetworkSettings::winServerName() + "/testshare/test.pri"
- << int(QNetworkReply::ProtocolUnknownError) << 0 << true;
-
// file: errors
QTest::newRow("file-host") << "file://this-host-doesnt-exist.troll.no/foo.txt"
#if !defined Q_OS_WIN