summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttpnetworkreply.cpp
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-01-11 12:24:15 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-01-11 14:27:13 (GMT)
commit36dcdcdf5b6869ded0401a879b1397ad9d20b324 (patch)
tree96d86590e989ed623f518b0648683c323ae6c002 /src/network/access/qhttpnetworkreply.cpp
parente2a94baeed03edbaeea9b4658f2a820520e1363f (diff)
downloadQt-36dcdcdf5b6869ded0401a879b1397ad9d20b324.zip
Qt-36dcdcdf5b6869ded0401a879b1397ad9d20b324.tar.gz
Qt-36dcdcdf5b6869ded0401a879b1397ad9d20b324.tar.bz2
QNAM HTTP: Fix readBuffer maximum size.
QHttpNetworkReply has now a throttled mode. If this is activated, it will only read HTTP body when its internal buffer is empty. This means that QNetworkReply.setReadBufferSize() can finally be used for bandwidth limiting. Thanks to David Faure for helping out. Reviewed-By: Peter Hartmann
Diffstat (limited to 'src/network/access/qhttpnetworkreply.cpp')
-rw-r--r--src/network/access/qhttpnetworkreply.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index 7025f1d..a5223d1 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -179,9 +179,19 @@ qint64 QHttpNetworkReply::bytesAvailableNextBlock() const
QByteArray QHttpNetworkReply::readAny()
{
Q_D(QHttpNetworkReply);
+ // we'll take the last buffer, so schedule another read from http
+ if (d->downstreamLimited && d->responseData.bufferCount() == 1)
+ d->connection->d_func()->readMoreLater(this);
return d->responseData.read();
}
+void QHttpNetworkReply::setDownstreamLimited(bool dsl)
+{
+ Q_D(QHttpNetworkReply);
+ d->downstreamLimited = dsl;
+ d->connection->d_func()->readMoreLater(this);
+}
+
bool QHttpNetworkReply::isFinished() const
{
return d_func()->state == QHttpNetworkReplyPrivate::AllDoneState;
@@ -201,7 +211,7 @@ QHttpNetworkReplyPrivate::QHttpNetworkReplyPrivate(const QUrl &newUrl)
forceConnectionCloseEnabled(false),
currentChunkSize(0), currentChunkRead(0), connection(0), initInflate(false),
autoDecompress(false), responseData(), requestIsPrepared(false)
- ,pipeliningUsed(false)
+ ,pipeliningUsed(false), downstreamLimited(false)
{
}