MCPcopy Create free account
hub / github.com/Qv2ray/Qv2ray / AsyncHttpGet

Method AsyncHttpGet

src/utils/HTTPRequestHelper.cpp:85–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83 }
84
85 void NetworkRequestHelper::AsyncHttpGet(const QString &url, std::function<void(const QByteArray &)> funcPtr)
86 {
87 QNetworkRequest request;
88 request.setUrl(url);
89 auto accessManagerPtr = new QNetworkAccessManager();
90 setAccessManagerAttributes(request, *accessManagerPtr);
91 auto reply = accessManagerPtr->get(request);
92 QObject::connect(reply, &QNetworkReply::finished, [=]() {
93 {
94#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
95 bool h2Used = reply->attribute(QNetworkRequest::Http2WasUsedAttribute).toBool();
96#else
97 bool h2Used = reply->attribute(QNetworkRequest::HTTP2WasUsedAttribute).toBool();
98#endif
99 if (h2Used)
100 DEBUG("HTTP/2 was used.");
101
102 if (reply->error() != QNetworkReply::NoError)
103 LOG("Network error: " + QString(QMetaEnum::fromType<QNetworkReply::NetworkError>().key(reply->error())));
104
105 funcPtr(reply->readAll());
106 accessManagerPtr->deleteLater();
107 }
108 });
109 }
110
111} // namespace Qv2ray::common::network

Callers 1

CheckUpdateMethod · 0.80

Calls 3

QStringClass · 0.85
keyMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected