QNetworkReply::setReadBufferSize seems ignored in 4.8.0
-
I use setReadBufferSize for QNetworkReply in 4.7.4. Immediate after QNetworkAccessManager::get I set some maximal buffer size using QNetworkReply::setReadBufferSize.
Then I read data by timer and everything works fine. When I check bytesAvailable() I see value as I expected, the value is very close to buffer size I set before.
When I migrated to 4.8.0 exactly same code stops working. It looks like setReadBufferSize is ignored and I see a huge value returned by bytesAvailable(). Is it a bug, or I missed something in 4.8.0?
-
Just to clarify my problem I isolated the issue to separate example:
readtest.h:
@#include <QObject>
class QNetworkAccessManager;
class QNetworkReply;
class ReadTest : public QObject
{
Q_OBJECTpublic:
ReadTest(const char *url);
protected:
void timerEvent(QTimerEvent *event);
private:
QNetworkAccessManager *_nam;
QNetworkReply *_nrp;
};
@
readtest.cpp:
@#include <QCoreApplication>
#include <QDebug>
#include <QNetworkAccessManager>
#include <QNetworkReply>#include "readbuff.h"
ReadTest::ReadTest(const char *url)
{
qDebug() << "ReadTest, reading url: " << url;
_nam = new QNetworkAccessManager(this);
_nrp = _nam->get(QNetworkRequest(QUrl(url)));
_nrp->setReadBufferSize(1048576);
startTimer(100);
}
void ReadTest::timerEvent(QTimerEvent *)
{
qDebug() << "bytesAvailable: " << _nrp->bytesAvailable();
_nrp->readAll();
}int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
if (argc > 1)
{
new ReadTest(argv[1]);
app.exec();
}
}
@You can run it and pass some url as an command line argument. When it compiled with Qt4.7.4. everything works fine and I see each time not more that 1M data available. When it compiled with Qt4.8.0 I see some huge number which depends only on network bandwidth.