Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QNetworkReply::setReadBufferSize seems ignored in 4.8.0
Forum Updated to NodeBB v4.3 + New Features

QNetworkReply::setReadBufferSize seems ignored in 4.8.0

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    alrez
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alrez
      wrote on last edited by
      #2

      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_OBJECT

      public:
      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved