summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2010-04-29 07:54:44 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2010-04-29 07:54:44 (GMT)
commitdcaad8949ea1c1782d27b038f08e9a728c8e3fe5 (patch)
tree3cb49a22f79c5952de4e913146659990d614cd64 /src/network
parent917e4e3284a568eecfca26365cc0a545d0f4eb70 (diff)
parent6940070adb45d67a0a9186205a4914a0a6c14135 (diff)
downloadQt-dcaad8949ea1c1782d27b038f08e9a728c8e3fe5.zip
Qt-dcaad8949ea1c1782d27b038f08e9a728c8e3fe5.tar.gz
Qt-dcaad8949ea1c1782d27b038f08e9a728c8e3fe5.tar.bz2
Merge remote branch 'origin/4.6' into qt-4.7-from-4.6
All EGL-related changes from 4.6 were discarded. Conflicts: src/gui/egl/egl.pri src/gui/egl/qegl.cpp src/gui/egl/qegl_p.h src/gui/egl/qegl_stub.cpp src/gui/egl/qeglproperties_p.h src/gui/egl/qeglproperties_stub.cpp src/gui/gui.pro src/multimedia/multimedia/audio/qaudioinput_win32_p.h src/s60installs/bwins/QtGuiu.def src/s60installs/eabi/QtGuiu.def
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp7
-rw-r--r--src/network/access/qnetworkaccesshttpbackend.cpp3
-rw-r--r--src/network/access/qnetworkreplyimpl.cpp75
-rw-r--r--src/network/access/qnetworkreplyimpl_p.h5
4 files changed, 62 insertions, 28 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 57d995a..3b7bc9e 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -317,6 +317,13 @@ void QHttpNetworkConnectionChannel::_q_receiveReply()
return;
}
+ // only run when the QHttpNetworkConnection is not currently being destructed, e.g.
+ // this function is called from _q_disconnected which is called because
+ // of ~QHttpNetworkConnectionPrivate
+ if (!qobject_cast<QHttpNetworkConnection*>(connection)) {
+ return;
+ }
+
qint64 bytes = 0;
QAbstractSocket::SocketState socketState = socket->state();
diff --git a/src/network/access/qnetworkaccesshttpbackend.cpp b/src/network/access/qnetworkaccesshttpbackend.cpp
index 7a48c2b..3154ed6 100644
--- a/src/network/access/qnetworkaccesshttpbackend.cpp
+++ b/src/network/access/qnetworkaccesshttpbackend.cpp
@@ -726,8 +726,7 @@ void QNetworkAccessHttpBackend::readFromHttp()
QByteDataBuffer list;
while (httpReply->bytesAvailable() != 0 && nextDownstreamBlockSize() != 0 && nextDownstreamBlockSize() > list.byteAmount()) {
- QByteArray data = httpReply->readAny();
- list.append(data);
+ list.append(httpReply->readAny());
}
if (!list.isEmpty())
diff --git a/src/network/access/qnetworkreplyimpl.cpp b/src/network/access/qnetworkreplyimpl.cpp
index 07a5bf3..128d18f 100644
--- a/src/network/access/qnetworkreplyimpl.cpp
+++ b/src/network/access/qnetworkreplyimpl.cpp
@@ -478,6 +478,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)
@@ -487,36 +518,12 @@ 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;
for (int i = 0; i < data.bufferCount(); i++) {
- QByteArray item = data[i];
+ QByteArray const &item = data[i];
if (cacheSaveDevice)
cacheSaveDevice->write(item.constData(), item.size());
@@ -529,6 +536,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);
@@ -572,6 +586,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 bc7e408..38084bd 100644
--- a/src/network/access/qnetworkreplyimpl_p.h
+++ b/src/network/access/qnetworkreplyimpl_p.h
@@ -156,8 +156,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();