summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp47
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp24
-rw-r--r--src/network/access/qnetworkreplyimpl_p.h14
3 files changed, 43 insertions, 42 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 7f36570..07a8b1d 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -57,7 +57,6 @@
#include "QtCore/qbuffer.h"
#include "QtCore/qurl.h"
#include "QtCore/qvector.h"
-#include "QtCore/qcoreapplication.h"
#include "QtNetwork/qauthenticator.h"
#include "QtNetwork/qsslconfiguration.h"
#include "QtNetwork/qnetworkconfigmanager.h"
@@ -760,46 +759,6 @@ bool QNetworkAccessManager::networkAccessEnabled() const
return d->networkAccessEnabled;
}
-class QDisabledNetworkReply : public QNetworkReply
-{
- Q_OBJECT
-
-public:
- QDisabledNetworkReply(QObject *parent, const QNetworkRequest &req,
- const QNetworkAccessManager::Operation op);
- ~QDisabledNetworkReply();
-
- void abort() { }
-protected:
- qint64 readData(char *, qint64) { return 0; }
-};
-
-QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent,
- const QNetworkRequest &req,
- QNetworkAccessManager::Operation op)
-: QNetworkReply(parent)
-{
- setRequest(req);
- setUrl(req.url());
- setOperation(op);
-
- qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
-
- QString msg = QCoreApplication::translate("QNetworkAccessManager",
- "Network access is disabled.");
- setError(UnknownNetworkError, msg);
-
- QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
- Q_ARG(QNetworkReply::NetworkError, UnknownNetworkError));
- QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
-}
-
-QDisabledNetworkReply::~QDisabledNetworkReply()
-{
-}
-
-#include "qnetworkaccessmanager.moc"
-
/*!
Returns a new QNetworkReply object to handle the operation \a op
and request \a req. The device \a outgoingData is always 0 for Get and
@@ -829,8 +788,12 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
return new QFileNetworkReply(this, req, op);
}
- if (!d->networkAccessEnabled)
+ // Return a disabled network reply if network access is disabled.
+ // Except if the scheme is empty or file://.
+ if (!d->networkAccessEnabled && !(req.url().scheme() == QLatin1String("file") ||
+ req.url().scheme().isEmpty())) {
return new QDisabledNetworkReply(this, req, op);
+ }
QNetworkRequest request = req;
if (!request.header(QNetworkRequest::ContentLengthHeader).isValid() &&
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 9721e32..3cf21f0 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -856,6 +856,30 @@ bool QNetworkReplyImplPrivate::migrateBackend()
return true;
}
+QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent,
+ const QNetworkRequest &req,
+ QNetworkAccessManager::Operation op)
+: QNetworkReply(parent)
+{
+ setRequest(req);
+ setUrl(req.url());
+ setOperation(op);
+
+ qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
+
+ QString msg = QCoreApplication::translate("QNetworkAccessManager",
+ "Network access is disabled.");
+ setError(UnknownNetworkError, msg);
+
+ QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
+ Q_ARG(QNetworkReply::NetworkError, UnknownNetworkError));
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
+}
+
+QDisabledNetworkReply::~QDisabledNetworkReply()
+{
+}
+
QT_END_NAMESPACE
#include "moc_qnetworkreplyimpl_p.cpp"
diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h
index 89b976f..639361e 100644
--- a/src/network/access/qnetworkreplyimpl_p.h
+++ b/src/network/access/qnetworkreplyimpl_p.h
@@ -193,6 +193,20 @@ public:
Q_DECLARE_PUBLIC(QNetworkReplyImpl)
};
+class QDisabledNetworkReply : public QNetworkReply
+{
+ Q_OBJECT
+
+public:
+ QDisabledNetworkReply(QObject *parent, const QNetworkRequest &req,
+ const QNetworkAccessManager::Operation op);
+ ~QDisabledNetworkReply();
+
+ void abort() { }
+protected:
+ qint64 readData(char *, qint64) { return -1; }
+};
+
QT_END_NAMESPACE
#endif