MCPcopy Create free account
hub / github.com/YACReader/yacreader / run

Method run

common/http_worker.cpp:39–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39void HttpWorker::run()
40{
41 QNetworkAccessManager manager;
42 QEventLoop q;
43 QTimer tT;
44
45 tT.setSingleShot(true);
46 connect(&tT, &QTimer::timeout, &q, &QEventLoop::quit);
47 connect(&manager, &QNetworkAccessManager::finished, &q, &QEventLoop::quit);
48
49 auto request = QNetworkRequest(url);
50
51 request.setHeader(QNetworkRequest::UserAgentHeader,
52 userAgent);
53
54 QNetworkReply *reply = manager.get(request);
55
56 tT.start(5000); // 5s timeout
57 q.exec();
58
59 if (tT.isActive()) {
60 // download complete
61 _error = !(reply->error() == QNetworkReply::NoError);
62 result = reply->readAll();
63 emit dataReady(result);
64 tT.stop();
65 } else {
66 _timeout = true;
67 emit timeout();
68 }
69}

Callers

nothing calls this directly

Calls 5

startMethod · 0.80
execMethod · 0.80
errorMethod · 0.80
getMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected