Created
April 14, 2015 08:48
-
-
Save guruz/bf90d9d5f4e61f3bd581 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QNetworkAccessManager> | |
#include <QEventLoop> | |
#include <QUrl> | |
#include <QDebug> | |
#include <QNetworkRequest> | |
#include <QNetworkReply> | |
#include <QObject> | |
#include <QCoreApplication> | |
#include <QTimer> | |
int main(int argc, char**argv) { | |
QCoreApplication app(argc,argv); | |
QNetworkAccessManager *manager = new QNetworkAccessManager(); | |
QNetworkReply* reply = manager->get(QNetworkRequest(QUrl("http://ipv4.download.thinkbroadband.com/5MB.zip"))); | |
int buffersize = 1024*1024*1; //1MB | |
reply->setReadBufferSize(buffersize); | |
QObject::connect(reply, &QNetworkReply::metaDataChanged, [reply,buffersize](){reply->setReadBufferSize(buffersize); qDebug() << buffersize;}); | |
QEventLoop loop; | |
QTimer::singleShot(15*1000,[&loop](){ loop.quit();}); | |
loop.exec(); | |
qDebug() << "Bytes available:" << reply->bytesAvailable() << "Buffer Size:" << buffersize; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment