summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qnetworkaccessbackend.cpp12
-rw-r--r--src/network/access/qnetworkaccessbackend_p.h1
-rw-r--r--src/network/access/qnetworkaccesscachebackend.cpp12
-rw-r--r--src/network/access/qnetworkaccesscachebackend_p.h2
-rw-r--r--src/network/access/qnetworkaccessdebugpipebackend.cpp6
-rw-r--r--src/network/access/qnetworkaccessdebugpipebackend_p.h1
-rw-r--r--src/network/access/qnetworkaccessfilebackend.cpp6
-rw-r--r--src/network/access/qnetworkaccessfilebackend_p.h1
-rw-r--r--src/network/access/qnetworkaccessftpbackend.cpp17
-rw-r--r--src/network/access/qnetworkaccessftpbackend_p.h1
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp20
-rw-r--r--src/network/access/qnetworkaccesshttpbackend_p.h1
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp21
13 files changed, 21 insertions, 80 deletions
diff --git a/src/network/access/qnetworkaccessbackend.cpp b/src/network/access/qnetworkaccessbackend.cpp
index 0a0987a..05eb6cb 100644
--- a/src/network/access/qnetworkaccessbackend.cpp
+++ b/src/network/access/qnetworkaccessbackend.cpp
@@ -88,18 +88,6 @@ QNetworkAccessBackendFactory::~QNetworkAccessBackendFactory()
QNetworkAccessBackend *QNetworkAccessManagerPrivate::findBackend(QNetworkAccessManager::Operation op,
const QNetworkRequest &request)
{
- QNetworkRequest::CacheLoadControl mode =
- static_cast<QNetworkRequest::CacheLoadControl>(
- request.attribute(QNetworkRequest::CacheLoadControlAttribute,
- QNetworkRequest::PreferNetwork).toInt());
- if (mode == QNetworkRequest::AlwaysCache
- && (op == QNetworkAccessManager::GetOperation
- || op == QNetworkAccessManager::HeadOperation)) {
- QNetworkAccessBackend *backend = new QNetworkAccessCacheBackend;
- backend->manager = this;
- return backend;
- }
-
if (!factoryDataShutdown) {
QMutexLocker locker(&factoryData()->mutex);
QNetworkAccessBackendFactoryData::ConstIterator it = factoryData()->constBegin(),
diff --git a/src/network/access/qnetworkaccessbackend_p.h b/src/network/access/qnetworkaccessbackend_p.h
index 4fe6de6..7faa5cb 100644
--- a/src/network/access/qnetworkaccessbackend_p.h
+++ b/src/network/access/qnetworkaccessbackend_p.h
@@ -115,7 +115,6 @@ public:
virtual bool start();
#endif
virtual void closeDownstreamChannel() = 0;
- virtual bool waitForDownstreamReadyRead(int msecs) = 0;
// slot-like:
virtual void downstreamReadyWrite();
diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp
index 73491a9..e78694e 100644
--- a/src/network/access/qnetworkaccesscachebackend.cpp
+++ b/src/network/access/qnetworkaccesscachebackend.cpp
@@ -132,18 +132,6 @@ void QNetworkAccessCacheBackend::closeUpstreamChannel()
Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!");
}
-bool QNetworkAccessCacheBackend::waitForDownstreamReadyRead(int)
-{
- Q_ASSERT_X(false, Q_FUNC_INFO , "This function show not have been called!");
- return false;
-}
-
-bool QNetworkAccessCacheBackend::waitForUpstreamBytesWritten(int)
-{
- Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!");
- return false;
-}
-
void QNetworkAccessCacheBackend::upstreamReadyRead()
{
Q_ASSERT_X(false, Q_FUNC_INFO, "This function show not have been called!");
diff --git a/src/network/access/qnetworkaccesscachebackend_p.h b/src/network/access/qnetworkaccesscachebackend_p.h
index df001ab..32581d5 100644
--- a/src/network/access/qnetworkaccesscachebackend_p.h
+++ b/src/network/access/qnetworkaccesscachebackend_p.h
@@ -69,8 +69,6 @@ public:
void open();
void closeDownstreamChannel();
void closeUpstreamChannel();
- bool waitForDownstreamReadyRead(int msecs);
- bool waitForUpstreamBytesWritten(int msecs);
void upstreamReadyRead();
void downstreamReadyWrite();
diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp
index cd077e7..5f99f84 100644
--- a/src/network/access/qnetworkaccessdebugpipebackend.cpp
+++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp
@@ -278,12 +278,6 @@ void QNetworkAccessDebugPipeBackend::socketConnected()
{
}
-bool QNetworkAccessDebugPipeBackend::waitForDownstreamReadyRead(int ms)
-{
- Q_UNUSED(ms);
- qCritical("QNetworkAccess: Debug pipe backend does not support waitForReadyRead()");
- return false;
-}
#endif
diff --git a/src/network/access/qnetworkaccessdebugpipebackend_p.h b/src/network/access/qnetworkaccessdebugpipebackend_p.h
index 58a4fd0..918a813 100644
--- a/src/network/access/qnetworkaccessdebugpipebackend_p.h
+++ b/src/network/access/qnetworkaccessdebugpipebackend_p.h
@@ -71,7 +71,6 @@ public:
virtual void open();
virtual void closeDownstreamChannel();
- virtual bool waitForDownstreamReadyRead(int msecs);
virtual void downstreamReadyWrite();
diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp
index 4560153..65f19ca 100644
--- a/src/network/access/qnetworkaccessfilebackend.cpp
+++ b/src/network/access/qnetworkaccessfilebackend.cpp
@@ -203,12 +203,6 @@ void QNetworkAccessFileBackend::closeDownstreamChannel()
}
}
-bool QNetworkAccessFileBackend::waitForDownstreamReadyRead(int)
-{
- Q_ASSERT(operation() == QNetworkAccessManager::GetOperation);
- return readMoreFromFile();
-}
-
void QNetworkAccessFileBackend::downstreamReadyWrite()
{
Q_ASSERT_X(operation() == QNetworkAccessManager::GetOperation, "QNetworkAccessFileBackend",
diff --git a/src/network/access/qnetworkaccessfilebackend_p.h b/src/network/access/qnetworkaccessfilebackend_p.h
index 6df8710..d1dbe8d 100644
--- a/src/network/access/qnetworkaccessfilebackend_p.h
+++ b/src/network/access/qnetworkaccessfilebackend_p.h
@@ -69,7 +69,6 @@ public:
virtual void open();
virtual void closeDownstreamChannel();
- virtual bool waitForDownstreamReadyRead(int msecs);
virtual void downstreamReadyWrite();
diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp
index 1a59011..d1a18d3 100644
--- a/src/network/access/qnetworkaccessftpbackend.cpp
+++ b/src/network/access/qnetworkaccessftpbackend.cpp
@@ -182,23 +182,6 @@ void QNetworkAccessFtpBackend::closeDownstreamChannel()
#endif
}
-bool QNetworkAccessFtpBackend::waitForDownstreamReadyRead(int ms)
-{
- if (!ftp)
- return false;
-
- if (ftp->bytesAvailable()) {
- ftpReadyRead();
- return true;
- }
-
- if (ms == 0)
- return false;
-
- qCritical("QNetworkAccess: FTP backend does not support waitForReadyRead()");
- return false;
-}
-
void QNetworkAccessFtpBackend::downstreamReadyWrite()
{
if (state == Transferring && ftp && ftp->bytesAvailable())
diff --git a/src/network/access/qnetworkaccessftpbackend_p.h b/src/network/access/qnetworkaccessftpbackend_p.h
index 737fa72..8a2bfc3 100644
--- a/src/network/access/qnetworkaccessftpbackend_p.h
+++ b/src/network/access/qnetworkaccessftpbackend_p.h
@@ -87,7 +87,6 @@ public:
virtual void open();
virtual void closeDownstreamChannel();
- virtual bool waitForDownstreamReadyRead(int msecs);
virtual void downstreamReadyWrite();
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index 2a0daf8..80b05a4 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -674,26 +674,6 @@ void QNetworkAccessHttpBackend::closeDownstreamChannel()
// this indicates that the user closed the stream while the reply isn't finished yet
}
-bool QNetworkAccessHttpBackend::waitForDownstreamReadyRead(int msecs)
-{
- Q_ASSERT(http);
-
- if (httpReply->bytesAvailable()) {
- readFromHttp();
- return true;
- }
-
- if (msecs == 0) {
- // no bytes available in the socket and no waiting
- return false;
- }
-
- // ### FIXME
- qCritical("QNetworkAccess: HTTP backend does not support waitForReadyRead()");
- return false;
-}
-
-
void QNetworkAccessHttpBackend::downstreamReadyWrite()
{
readFromHttp();
diff --git a/src/network/access/qnetworkaccesshttpbackend_p.h b/src/network/access/qnetworkaccesshttpbackend_p.h
index 568b2ee..5de3429 100644
--- a/src/network/access/qnetworkaccesshttpbackend_p.h
+++ b/src/network/access/qnetworkaccesshttpbackend_p.h
@@ -79,7 +79,6 @@ public:
virtual void open();
virtual void closeDownstreamChannel();
- virtual bool waitForDownstreamReadyRead(int msecs);
virtual void downstreamReadyWrite();
virtual void setDownstreamLimited(bool b);
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index e5f4d5a..effd79e 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -54,6 +54,7 @@
#include "qnetworkaccessfilebackend_p.h"
#include "qnetworkaccessdatabackend_p.h"
#include "qnetworkaccessdebugpipebackend_p.h"
+#include "qnetworkaccesscachebackend_p.h"
#include "qfilenetworkreply_p.h"
#include "QtCore/qbuffer.h"
@@ -970,6 +971,26 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
return new QFileNetworkReply(this, req, op);
}
+ // A request with QNetworkRequest::AlwaysCache does not need any bearer management
+ QNetworkRequest::CacheLoadControl mode =
+ static_cast<QNetworkRequest::CacheLoadControl>(
+ req.attribute(QNetworkRequest::CacheLoadControlAttribute,
+ QNetworkRequest::PreferNetwork).toInt());
+ if (mode == QNetworkRequest::AlwaysCache
+ && (op == QNetworkAccessManager::GetOperation
+ || op == QNetworkAccessManager::HeadOperation)) {
+ // FIXME Implement a QNetworkReplyCacheImpl instead, see QTBUG-15106
+ QNetworkReplyImpl *reply = new QNetworkReplyImpl(this);
+ QNetworkReplyImplPrivate *priv = reply->d_func();
+ priv->manager = this;
+ priv->backend = new QNetworkAccessCacheBackend();
+ priv->backend->manager = this->d_func();
+ priv->backend->setParent(reply);
+ priv->backend->reply = priv;
+ priv->setup(op, req, outgoingData);
+ return reply;
+ }
+
#ifndef QT_NO_BEARERMANAGEMENT
// Return a disabled network reply if network access is disabled.
// Except if the scheme is empty or file://.