/** * This helper function sends a stream with the given number of bytes. * After the stream is sent, it is read back and compared. * @param nbOfBytes Stream length * @param chunked If true, the stream is sent with chunked encoding. If false, the HTTP request is sent with the Content-Length header. */ void internalTestStreams(int64_t nbOfBytes, bool chunked) { l_info << L"internalTestStreams(chunked=" << chunked << L", nbOfBytes=" << nbOfBytes; PContentStream strm(new MyContentStreamBytes(nbOfBytes, chunked)); // send stream PRemoteStreams remote = client->getRemoteStreams(); l_info << L"remote->setImage..."; remote->setImage(strm); l_info << L"remote->setImage OK"; bool checkContent = true; if (checkContent) { // read stream and compare bytes l_info << L"remote->getImage..."; PContentStream strmR = remote->getImage(); l_info << L"remote->getImage OK"; checkStreamContent(strm, strmR); strmR.reset(); } l_info << L")internalTestStreams"; }
int main(int argc, char *argv[]) { qInstallMessageHandler(myMessageOutput); QCoreApplication a(argc, argv); // Task parented to the application so that it // will be deleted by the application. Task *task = new Task(&a); // This will cause the application to exit when // the task signals finished. QObject::connect(task, SIGNAL(finished()), &a, SLOT(quit())); // This will run the task from the application event loop. QTimer::singleShot(0, task, SLOT(run())); int ret = a.exec(); strm.reset(); hget.reset(); client.reset(); return ret; }