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:

    @#include <QObject>
    class QNetworkAccessManager;
    class QNetworkReply;
    class ReadTest : public QObject

    ReadTest(const char *url);
    void timerEvent(QTimerEvent *event);
    QNetworkAccessManager *_nam;
    QNetworkReply *_nrp;
    @#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)));
    void ReadTest::timerEvent(QTimerEvent *)
    qDebug() << "bytesAvailable: " << _nrp->bytesAvailable();

    int main(int argc, char *argv[])
    QCoreApplication app(argc, argv);
    if (argc > 1)
    new ReadTest(argv[1]);

    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.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.