Qt World Summit: Submit your Presentation

QNetworkReply::setReadBufferSize still ignored

  • Lets see follow small test for QNetworkReply::setReadBufferSize behavour

    readtest.pro: @QT += network
    SOURCES = readtest.cpp
    HEADERS = readtest.h

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

    ReadTest(const char *url);

    void timerEvent(QTimerEvent *event);
    QNetworkAccessManager *_access_mgr;
    QNetworkReply *_request;

    readtest.cpp: @#include <QCoreApplication>
    #include <QDebug>
    #include <QNetworkAccessManager>
    #include <QNetworkReply>

    #include "readtest.h"

    ReadTest::ReadTest(const char *url)
    qDebug() << "ReadTest, reading url: " << url;
    _access_mgr = new QNetworkAccessManager(this);
    _request = _access_mgr->get(QNetworkRequest(QUrl(url)));
    void ReadTest::timerEvent(QTimerEvent *)
    qDebug() << "bytesAvailable: " << _request->bytesAvailable();

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

    I start this application from command line using some URL as first parameter. I expect QNetworkReply::setReadBufferSize will limit buffer usage and I never see _request->bytesAvailable() more than QNetworkReply::setReadBufferSize value (1048576 in this example).

    It works excactly that way, when the example compiled with Qt4.7.4. When it compled with Qt4.8.0 or 4.8.1 I see some huge number instead which depends only on network bandwidth.

    Is this bug or my misunderstanding?

Log in to reply