summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkreplyhttpimpl.cpp
diff options
context:
space:
mode:
authorMartin Petersson <Martin.Petersson@nokia.com>2012-05-07 12:41:58 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-11 10:38:25 +0200
commita050bba2f0151beb508fa7ab6f58c25c4e92bfb0 (patch)
tree82d65e9f02bccac3e847d0824092c779b92369c9 /src/network/access/qnetworkreplyhttpimpl.cpp
parent1211fd0b6116ca64468780bff12e7902576ab041 (diff)
QNetworkReply::setReadBufferSize fix for threaded http
Added the setReadBufferSize functionallity again by limiting the amount that the delegate read from the channel. Each time that data is fetched from the reply buffer, we communicate back to the thread so that more data can be fetched. Task-number: QTBUG-25327 Change-Id: I2f9950196e64acd09bc8da50c1116f2c9deacad4 Reviewed-by: Shane Kearns <shane.kearns@accenture.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/network/access/qnetworkreplyhttpimpl.cpp')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index c9ec287c2c..25b73e969f 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -357,17 +357,22 @@ qint64 QNetworkReplyHttpImpl::readData(char* data, qint64 maxlen)
if (maxlen == 1) {
// optimization for getChar()
*data = d->downloadMultiBuffer.getChar();
+ if (readBufferSize())
+ emit readBufferFreed(1);
return 1;
}
maxlen = qMin<qint64>(maxlen, d->downloadMultiBuffer.byteAmount());
- return d->downloadMultiBuffer.read(data, maxlen);
+ qint64 bytesRead = d->downloadMultiBuffer.read(data, maxlen);
+ if (readBufferSize())
+ emit readBufferFreed(bytesRead);
+ return bytesRead;
}
void QNetworkReplyHttpImpl::setReadBufferSize(qint64 size)
{
- Q_UNUSED(size);
- // FIXME, unsupported right now
+ QNetworkReply::setReadBufferSize(size);
+ emit readBufferSizeChanged(size);
return;
}
@@ -839,6 +844,10 @@ void QNetworkReplyHttpImplPrivate::postRequest()
QObject::connect(q, SIGNAL(startHttpRequest()), delegate, SLOT(startRequest()));
QObject::connect(q, SIGNAL(abortHttpRequest()), delegate, SLOT(abortRequest()));
+ // To throttle the connection.
+ QObject::connect(q, SIGNAL(readBufferSizeChanged(qint64)), delegate, SLOT(readBufferSizeChanged(qint64)));
+ QObject::connect(q, SIGNAL(readBufferFreed(qint64)), delegate, SLOT(readBufferFreed(qint64)));
+
if (uploadByteDevice) {
QNonContiguousByteDeviceThreadForwardImpl *forwardUploadDevice =
new QNonContiguousByteDeviceThreadForwardImpl(uploadByteDevice->atEnd(), uploadByteDevice->size());