summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-04-07 12:17:53 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-04-26 15:16:21 (GMT)
commited692616c6a358ccfbdb10b716d6d5829a92f7bb (patch)
tree4bf750c793f6b22f98617872ac8991877489c97e /src
parentb7fa0c137c2ef567b286d83435aba843e33280b7 (diff)
downloadQt-ed692616c6a358ccfbdb10b716d6d5829a92f7bb.zip
Qt-ed692616c6a358ccfbdb10b716d6d5829a92f7bb.tar.gz
Qt-ed692616c6a358ccfbdb10b716d6d5829a92f7bb.tar.bz2
QNAM HTTP: Divide QNetworkReplyImplPrivate::appendDownstreamData
The goal is to easier add an overload for (const &QByteArray). Reviewed-by: Peter Hartmann
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp73
-rw-r--r--src/network/access/qnetworkreplyimpl_p.h5
2 files changed, 53 insertions, 25 deletions
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 320b1ac..4f35358 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -403,6 +403,37 @@ qint64 QNetworkReplyImplPrivate::nextDownstreamBlockSize() const
return qMax<qint64>(0, readBufferMaxSize - readBuffer.byteAmount());
}
+void QNetworkReplyImplPrivate::initCacheSaveDevice()
+{
+ Q_Q(QNetworkReplyImpl);
+
+ // save the meta data
+ QNetworkCacheMetaData metaData;
+ metaData.setUrl(url);
+ metaData = backend->fetchCacheMetaData(metaData);
+
+ // save the redirect request also in the cache
+ QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute);
+ if (redirectionTarget.isValid()) {
+ QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes();
+ attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget);
+ metaData.setAttributes(attributes);
+ }
+
+ cacheSaveDevice = networkCache()->prepare(metaData);
+
+ if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) {
+ if (cacheSaveDevice && !cacheSaveDevice->isOpen())
+ qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- "
+ "class %s probably needs to be fixed",
+ networkCache()->metaObject()->className());
+
+ networkCache()->remove(url);
+ cacheSaveDevice = 0;
+ cacheEnabled = false;
+ }
+}
+
// we received downstream data and send this to the cache
// and to our readBuffer (which in turn gets read by the user of QNetworkReply)
void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data)
@@ -412,31 +443,7 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data)
return;
if (cacheEnabled && !cacheSaveDevice) {
- // save the meta data
- QNetworkCacheMetaData metaData;
- metaData.setUrl(url);
- metaData = backend->fetchCacheMetaData(metaData);
-
- // save the redirect request also in the cache
- QVariant redirectionTarget = q->attribute(QNetworkRequest::RedirectionTargetAttribute);
- if (redirectionTarget.isValid()) {
- QNetworkCacheMetaData::AttributesMap attributes = metaData.attributes();
- attributes.insert(QNetworkRequest::RedirectionTargetAttribute, redirectionTarget);
- metaData.setAttributes(attributes);
- }
-
- cacheSaveDevice = networkCache()->prepare(metaData);
-
- if (!cacheSaveDevice || (cacheSaveDevice && !cacheSaveDevice->isOpen())) {
- if (cacheSaveDevice && !cacheSaveDevice->isOpen())
- qCritical("QNetworkReplyImpl: network cache returned a device that is not open -- "
- "class %s probably needs to be fixed",
- networkCache()->metaObject()->className());
-
- networkCache()->remove(url);
- cacheSaveDevice = 0;
- cacheEnabled = false;
- }
+ initCacheSaveDevice();
}
qint64 bytesWritten = 0;
@@ -454,6 +461,13 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QByteDataBuffer &data)
bytesDownloaded += bytesWritten;
lastBytesDownloaded = bytesDownloaded;
+ appendDownstreamDataSignalEmissions();
+}
+
+void QNetworkReplyImplPrivate::appendDownstreamDataSignalEmissions()
+{
+ Q_Q(QNetworkReplyImpl);
+
QPointer<QNetworkReplyImpl> qq = q;
QVariant totalSize = cookedHeaders.value(QNetworkRequest::ContentLengthHeader);
@@ -495,6 +509,15 @@ void QNetworkReplyImplPrivate::appendDownstreamData(QIODevice *data)
_q_copyReadyRead();
}
+void QNetworkReplyImplPrivate::appendDownstreamData(const QByteArray &data)
+{
+ // TODO implement
+
+ // TODO call
+
+ qFatal("QNetworkReplyImplPrivate::appendDownstreamData not implemented");
+}
+
void QNetworkReplyImplPrivate::finished()
{
Q_Q(QNetworkReplyImpl);
diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h
index 168e5cf..a7a568a 100644
--- a/src/network/access/qnetworkreplyimpl_p.h
+++ b/src/network/access/qnetworkreplyimpl_p.h
@@ -145,8 +145,13 @@ public:
void consume(qint64 count);
void emitUploadProgress(qint64 bytesSent, qint64 bytesTotal);
qint64 nextDownstreamBlockSize() const;
+
+ void initCacheSaveDevice();
+ void appendDownstreamDataSignalEmissions();
void appendDownstreamData(QByteDataBuffer &data);
void appendDownstreamData(QIODevice *data);
+ void appendDownstreamData(const QByteArray &data);
+
void finished();
void error(QNetworkReply::NetworkError code, const QString &errorString);
void metaDataChanged();